Info
この質問は閉じられています。 編集または回答するには再度開いてください。
For loop help needed
1 回表示 (過去 30 日間)
古いコメントを表示
How would I write the following equations in a for loop?
rho = 1.2*exp(h^1.15)
D = .5*rho
Uy=D*cos(theta)
Ux=D*sin(theta)
h_t+dt=h_t+Uy*dt
theta_t+dt=atan(Ux/Uy)
I have an initial value of h=0 and theta=0.
Someone please help. The way I'm thinking about it now creates a circular loop so I don't know what to do.
3 件のコメント
Roger Stafford
2016 年 3 月 17 日
By any chance, are the last two equations supposed to represent the differential equations:
dh/dt = h + Uy
dtheta/dt = atan(Ux/Uy)
If so, you should use, for example, 'ode45' to solve these equations.
The notation you have used is not in accordance with usual mathematical practice. Try expressing your idea in ordinary English rather than mathematical equations to see if you can get your idea across to those of us in this forum.
回答 (1 件)
John BG
2016 年 3 月 18 日
Correct if wrong but your start equations really are:
rho = 1.2*exp(h^1.15)
D = .5*rho
Uy=D*cos(theta)
Ux=D*sin(theta)
h(t+dt)=h(t)+Uy*dt
theta(t+dt)=atan(Ux/Uy)
Simplifying,
D = .6*exp(h^1.15) % rid rho
d(h(t))/dt=Uy
d(theta(t))/dt=atan(Ux/Uy)
Ux/Uy=cos(theta)/sin(theta)
because
atan(Ux/Uy)=atan(cos(theta)./sin(theta))=pi/2*sawtooth(2*theta)
testing this:
x = -6*pi:0.01:6*pi
axis([-6*pi 6*pi -2 2])
hold all
plot(x,atan(cos(x)./sin(x)));grid on
plot(x,pi/2*sawtooth(2*x,0))
then, probably, your start DE system is:
dot_h=U.6*exp(h^1.15)*cos(theta)
dot_theta=pi/2*sawtooth(2*theta)
Over to you, can you solve this? or do you need further help?
If you find this answer of any help solving your question, please click on the thumbs-up vote link,
thanks in advance
John
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!