While Loops (HELP!!)
Show older comments
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
Answers (1)
Honglei Chen
on 22 Mar 2012
0 votes
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?
Categories
Find more on Material Sciences in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!