Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

For loop help needed

3 vues (au cours des 30 derniers jours)
Shannon Hemp
Shannon Hemp le 17 Mar 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
Shannon Hemp
Shannon Hemp le 17 Mar 2016
I want to find the values of Ux and Uy for time 0 to 10 seconds
Roger Stafford
Roger Stafford le 17 Mar 2016
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.

Réponses (1)

John BG
John BG le 18 Mar 2016
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

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by