- #1
oceanspiral20
- 5
- 0
Hi!
I have an array that is 1 column by many rows, of which each element represents a time. I want to find variable f at each time, where f is defined as follows:
if t < tp
f=(sin((pi*t)/(2*tp)))^2;
if tp < t < ts
f=(cos((pi*(t-tp))/(2*(ts-tp))))^2;
otherwise f=0
I've tried defining f as above in a .m function file (called elastance), and then using f=arrayfun(elastance,t) to find f at each time, but that doesn't work (It says, "Error in ==> elastance at 5, if t < tp".) Just typing the above function directly into the command window doesn't work either, whether or not I put it in terms of t or (t.).
Does anyone have any suggestions? Thanks!
I have an array that is 1 column by many rows, of which each element represents a time. I want to find variable f at each time, where f is defined as follows:
if t < tp
f=(sin((pi*t)/(2*tp)))^2;
if tp < t < ts
f=(cos((pi*(t-tp))/(2*(ts-tp))))^2;
otherwise f=0
I've tried defining f as above in a .m function file (called elastance), and then using f=arrayfun(elastance,t) to find f at each time, but that doesn't work (It says, "Error in ==> elastance at 5, if t < tp".) Just typing the above function directly into the command window doesn't work either, whether or not I put it in terms of t or (t.).
Does anyone have any suggestions? Thanks!