Why does my index exceed array bounds for the following for loop?

lamda = 0:500; %s^-1
mewp = .012; %Poise
for i = 1:length(lamda)
mewapp = mewp(2.3409.*lamda(i) + 6.12.*sqrt(lamda(i))+4);
figure(1)
hold on
plot (lamda(i),mewapp);
end
error message
Index exceeds array bounds.
Error in Problem3_b (line 4)
mewapp = mewp(2.3409.*lamda(i) + 6.12.*sqrt(lamda(i))+4);

Answers (1)

You don’t need a loop
mewp*
% ^-—-—-missed it

1 Comment

lamda = 0:500; %s^-1
mewp = .012; %Poise
mewapp = mewp*(2.3409*lamda + 6.12*sqrt(lamda)+4);
plot (lamda,mewapp)
If you want to see the movement of the plot:
figure
comet(lamda,mewapp)

Sign in to comment.

Asked:

on 15 Feb 2019

Commented:

on 15 Feb 2019

Community Treasure Hunt

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

Start Hunting!