필터 지우기
필터 지우기

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