Why does my index exceed array bounds for the following for loop?
Afficher commentaires plus anciens
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);
Réponses (1)
madhan ravi
le 15 Fév 2019
You don’t need a loop
mewp*
% ^-—-—-missed it
1 commentaire
madhan ravi
le 15 Fév 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)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!