Info

此问题已关闭。 请重新打开它进行编辑或回答。

For loop help needed

3 次查看(过去 30 天)
Shannon Hemp
Shannon Hemp 2016-3-17
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Shannon Hemp
Shannon Hemp 2016-3-17
I want to find the values of Ux and Uy for time 0 to 10 seconds
Roger Stafford
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
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

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by