Hello everyone, I keep getting the classic error message of 'Index exceeds the number of array elements (169)'. Here is my code, it's a very simple while loop:
syms T h
T (h) = ((288.19-0.00649.*h));
h = linspace (7620,11000,169); %Every step is 20m change in altitude
D = vpa(T(h),4);
s = 1;
while s <= 169
rho(s) = 1.225*(D(h)/288.19)^((9.80665/(0.0065*286))-1);
s = s+1;
end
I really don't see where I've gone wrong. I have other while loops that follow the same structure and they work perfectly. Any help would be appreciated. Thanks in advance!

 Akzeptierte Antwort

David Hill
David Hill am 1 Apr. 2021
Bearbeitet: David Hill am 1 Apr. 2021
No need for any loops. No need for symbolics.
h = linspace (7620,11000,169);
D = 288.19-0.00649.*h;
rho= 1.225*(D/288.19).^(9.80665/0.0065/286-1);

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by