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 Kommentar

per isakson
per isakson am 6 Okt. 2015
Bearbeitet: per isakson am 6 Okt. 2015
Any error messages?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Okt. 2015

0 Stimmen

"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 Kommentare

Syed Muhammad Umar
Syed Muhammad Umar am 6 Okt. 2015
So how can be the new code is Can you please write it down
Syed Muhammad Umar
Syed Muhammad Umar am 6 Okt. 2015
Bearbeitet: Walter Roberson am 6 Okt. 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 am 6 Okt. 2015
It looks plausible.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Acoustics, Noise and Vibration finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by