??? Undefined function or method 'sign' for input arguments of type 'sym'.
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to generate a wave :
when time=0:5 then r(t)=1
when time=5:10 then r(t)=2
when time=10:15 then r(t)=1
and then I also want to take derivative of this wave (even double derivative also)
I tried it without giving t=0:15 and with syms
code:
t= 0:0.1:14.9;
aaa=sin(2*pi*0.1*t');
% %r = [1,zeros(120,1)]+2-sign(aaa);
r =2.000-sign(aaa);
size(r)
r1=diff(r,t);
size(r1)
rp=horzcat(0,r1);
size(rp)
size(t)
plot(t',rp)
------
error:when time=0:5 then r(t)=1
I also tried with if loop ,
if t>=0 && t<=5
r=1;
if t>=5 && t<=10
r=2;
if t>=10 && t<=15
r=1;
this aslo doesnot work; give some logical error message
please help
댓글 수: 1
Walter Roberson
2013년 8월 25일
There is no such thing as an "if loop". There are "for loop" and "while loop" and "if statement".
채택된 답변
Walter Roberson
2013년 8월 25일
"when" is not a MATLAB or MuPAD command.
Your code does not use sym() or syms, so you could not be getting an error about sign of sym.
Your "t" is a vector, so "t>=0" is a vector result as is "t<=5". You cannot join vector results with "&&" as "&&" is reserved for scalars. You need to use "&" to join vector results. But you should probably read the definition of how "if" works carefully
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!