While Loops (HELP!!)

I have an assignment due ASAP that I absolutely can not figure out. Basically I need to use 2 while loops to solve this problem:
Basically I don't understand the index 'i' part of it or how to input the equations into Matlab. Any help would be more than appreciated as I am late for this assignment and am stressing out really badly.
Here is what I have as the solution so far (it isn't right but probably close):
% Parameters
D = 10; % diameter
Y = 4000; % altitude
T = 40; % time of free-fall
M = 80; % mass of skydiver
% Constants
g = 9.81; % gravitational acceleration constant
pair = 1.225; % density of air
t=1;
i=1;
while Y>1000 & t<T
A=0.5;
Cd=0.7;
V=0.99*sqrt((2*M*g)/(pair*A*Cd));
ai=((1/2)*(pair/M)*Vi-1^2*A*Cd)-g;
Vi=Vi-1+(ai*(T-t))
t=t+1;
i=i+1;
end
while Y<=1000
A=(pi/4)*(D^2);
Cd=1.4;
V=0.99*sqrt((2*M*g)/(pair*A*Cd));
ai=((1/2)*(pair/M)*Vi-1^2*A*Cd)-g;
Vi=Vi-1+(ai*(T-t))
t=t+1
i=i+1;
end

回答(1 个)

Honglei Chen
Honglei Chen 2012-3-22

0 个投票

You need to update your Y in each loop otherwise time goes by and the altitude of the skydiver never changes. See the equation in your problem regarding how to update Y.
In addition, you may also add another condition to stop the second while loop, such as after the skydiver landed?

类别

帮助中心File Exchange 中查找有关 Material Sciences 的更多信息

标签

提问:

2012-3-22

Community Treasure Hunt

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

Start Hunting!

Translated by