Array indices must be positive integers or logical values.

Not really sure what I did wrong. I think it's my Rho list but I'm honestly unsure. Any input is greatly appreciated :)
C_L = 0.5;
C_D = 0.02;
L= 600; %lb
AR = 480; %ft^2
Alt = 12000; %ft
Angle_Climb = (C_D/C_L)*180/pi; %degrees
Rho =[0.00164779,0.00167423,0.00170099,0.00172808,0.00175549,0.00178324,0.00181132,0.00183974,0.00186850,0.00189760,0.00192704,0.00195684,0.00198698,0.00201748,0.00204834,0.00207956,0.00211114,0.00214308,0.00217539,0.00220808,0.00224114,0.00227457,0.00230839,0.00234259,0.00237717];
Rng = 0;
V_test = [];
V_y = [];
V_x = [];
t = [];
d=[];
for k=1:25
V = (2.*L./(Rho(k).*AR.*C_L)).^(1./2);
V_test(k) = V;
V_y(k) = V_test(k).*sin(0.04);
V_x(k) = V_test(k).*cos(0.04);
t(k) =500./V_y(k);
d(k) = V_x(k)./t(k);
end
display(V_test)

 Accepted Answer

The code you posted runs for me without error.
What line is throwing the error when you run it?

2 Comments

I realized that I had to use disp() instead of display() to display the array. Thanks for the help!
As always, my pleasure!
The display function should work:
display(pi)
Do you have a variable called display? To find out, run this:
q = which('display','-all')
You should only get a long list of results that begin with:
q =
187×1 cell array
{'built-in (C:\Program Files\MATLAB\R2019a\toolbox\matlab\lang\display)' }
If the first entry is:
display is a variable.
you’ve found the problem. The solution is to rename the variable to something that doesn’t overshadow the name of any MATLAB function.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!