Point out the error

조회 수: 1 (최근 30일)
Syed Muhammad Umar
Syed Muhammad Umar 2015년 10월 6일
댓글: Walter Roberson 2015년 10월 6일
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
per isakson
per isakson 2015년 10월 6일
편집: per isakson 2015년 10월 6일
Any error messages?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2015년 10월 6일
"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
Syed Muhammad Umar
Syed Muhammad Umar 2015년 10월 6일
편집: Walter Roberson 2015년 10월 6일
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 2015년 10월 6일
It looks plausible.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Acoustics, Noise and Vibration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by