Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

For loop help needed

3 Ansichten (letzte 30 Tage)
Shannon Hemp
Shannon Hemp am 17 Mär. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 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 Kommentare
Shannon Hemp
Shannon Hemp am 17 Mär. 2016
I want to find the values of Ux and Uy for time 0 to 10 seconds
Roger Stafford
Roger Stafford am 17 Mär. 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.

Antworten (1)

John BG
John BG am 18 Mär. 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

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by