??? Undefined function or method 'sign' for input arguments of type 'sym'.

1 visualización (últimos 30 días)
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 comentario
Walter Roberson
Walter Roberson el 25 de Ag. de 2013
There is no such thing as an "if loop". There are "for loop" and "while loop" and "if statement".

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Ag. de 2013
"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

Más respuestas (0)

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by