Index exceeds the number of array elements in a while loop
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!