フィルターのクリア

use of matlab in physics

4 ビュー (過去 30 日間)
Tor Fredrik Hove
Tor Fredrik Hove 2012 年 2 月 3 日
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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by