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

1 回表示 (過去 30 日間)
Joseph Ulbrich
Joseph Ulbrich 2019 年 2 月 15 日
コメント済み: madhan ravi 2019 年 2 月 15 日
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);

回答 (1 件)

madhan ravi
madhan ravi 2019 年 2 月 15 日
You don’t need a loop
mewp*
% ^-—-—-missed it
  1 件のコメント
madhan ravi
madhan ravi 2019 年 2 月 15 日
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)

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by