Why does my index exceed array bounds for the following for loop?
1 view (last 30 days)
Show older comments
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);
0 Comments
Answers (1)
madhan ravi
on 15 Feb 2019
You don’t need a loop
mewp*
% ^-—-—-missed it
1 Comment
madhan ravi
on 15 Feb 2019
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)
See Also
Categories
Find more on 2-D and 3-D Plots 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!