use of matlab in physics

4 次查看(过去 30 天)
You have a force from many forces that is
F=F+Fc-Fv-D
where
F=400 N
Fc=488*exp(-(t/0.67)^2) N
Fv=25.8v
D=0.34911(1-0.25*exp(-(t/0.67)^2)*v^2
i was asked to use eulers method to calculate in matlab the position of a runner who is moving with these forces (F is moving forward motion, Fc is extra motion forward when body is leaned and back is curled, Fv is a force that prevents F to continue to infinity and decreases acceleration as function of v of runner and D is airdrag)
here is what i wrote but without clearly getting a right answer:
vl=[];
x=[];
t=[];
a=[];
vl(1)=0;
n=2;
x(1)=0;
t(1)=0;
dt=0.05;
while x(n-1)<100
F=5;
Fc=6.1*exp(-(t(n-1)/0.67)^2);
Fv=25.8*vl(n-1);
D=0.34911*(1-0.25*exp(-(t(n-1)/0.67)^2))*(vl(n-1))^2;
a(n-1)=F+Fc-Fv-D
vl(n)=vl(n-1)+a(n-1)*dt;
x(n)=x(n-1)+vl(n)*dt;
t(n)=t(n-1)+dt;
n=n+1;
end
plot(t,vl,'r');
hold on
plot(t,x,'g');
legend('vl','x');

采纳的回答

the cyclist
the cyclist 2012-2-3
I notice two things:
  1. You run your while loop out to x=100 or so, but with the constants you have, all the interesting action is taking place at x<1. Temporarily, you might consider changing the limit to x(n-1)<1, while you debug.
  2. You divided two of your force constants (F and Fc) by a factor of 80, but you did not do the same with the other two (Fv and D). I did not look in detail (something with units, which you did not specify?), but that might lead to the current incorrect behavior, where the runner reaches top velocity in about a second.
I suggest you write out your equations with the units included, to ensure that the units all match.
There are also some significant MATLAB-specific improvements that could be made to your code, but I think you should focus on getting the physics/math correct first.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by