MATLAB: Matlab for loop error with ‘>=’

for loop

Dear Matlab gurus,
Having trouble plotting several graphs using a for loop. Error comes upto '>='. Tried with '>' only, and it too won't work.
"Error: File: ******.m Line: 14 Column: 7 Unexpected MATLAB operator."
I'm not too good at computing. Help would be much appreciated.
Thanks,
Kelvin
% Drag force coefficient
c = 1.3
% Surface area of skydiver - m^2
A = 1.2
% Altitude - m
h = 40000
% Atmospheric pressure - Pa
p = 101325
% Specific gas constant for dry air - J/kg K
R = 287.058
% Density - mol
D = P/R.*T
for h >= 0
% Temperature - K
T = -1.033.*10.^-16.*h.^4 + 3.344.*10.^-12.*h.^3 + 2.521.*10.^7.*h.^2 - 0.009527.*h + 293;
% Pressure
P = p.*(1 - 2.256.*10.^-5.*h).^5.256;
% Drag Force
F = 1/2.*p.*v.^2.*c.*A;
h = h - 1;
end
% Q1
figure(1);
plot(T, h)
title('Temperature as a fn of Altitude')
xlabel('Temperature (K)')
ylabel('Height (m)')
% Q2
figure(2);
plot(P, h)
title('Pressure as a fn of Altitude')
xlabel('Pressure (Pa)')
ylabel('Height (m)')
% Q3
figure(3);
plot (D, h)
title('Density as a fn of Altitude')
xlabel('Density (mol.)')
ylabel('Height (m)')

Best Answer

It doesn't make sense. What is x??? You didn't define it. Even if you did, you would use "if" or "while" instead of "for". And if you used a while, x would have to change within the loop or else the loop would never end.