Point out the error

1 visualización (últimos 30 días)
Syed Muhammad Umar
Syed Muhammad Umar el 6 de Oct. de 2015
Comentada: Walter Roberson el 6 de Oct. de 2015
Matlab script to animate the motion of vibrating guitar
A= 2;
L= 10;
f= 50;
ta= 2;
x=0:0.1:L;
T=5 ;
t=0;
for t < T
y=(A)*(exp^(-t/ta))*(sin((2*pi*x)/L))*(cos(2*pi*f*t));
plot(x,y)
t=t+0.1;
pause(0.5)
end
  1 comentario
per isakson
per isakson el 6 de Oct. de 2015
Editada: per isakson el 6 de Oct. de 2015
Any error messages?

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Oct. de 2015
"for" must be followed by a variable name and then by an "=" and then an expression. The "for" loop will then be repeated assigning the values of the expression to the variable in turn.
You probably want "while" instead of "for"
  3 comentarios
Syed Muhammad Umar
Syed Muhammad Umar el 6 de Oct. de 2015
Editada: Walter Roberson el 6 de Oct. de 2015
Is it Okay
A= 2;
L= 10;
f= 50;
ta= 2;
x=0:0.1:L;
t= 0;
T=5 ;
exp=2.718;
while t < T
y=(A)*(exp^(-t/ta))*(sin((2*pi*x)/L))*(cos(2*pi*f*t));
plot(x,y)
t=t+0.1;
pause(0.5)
end
Walter Roberson
Walter Roberson el 6 de Oct. de 2015
It looks plausible.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Acoustics, Noise and Vibration en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by