Create a plot with a function in a loop?

3 ビュー (過去 30 日間)
Julien B
Julien B 2015 年 11 月 25 日
編集済み: Julien B 2015 年 11 月 25 日
Hi,
here is my code:
E = zeros(1,10);
Ith = 100
for k = 1:1:10
N=2^k ;
I = 0;
for i=1:1:N
I = I + h*f(((xmin+i*h)+(xmin+(i-1)*h))/2);
end
E(k) = (I - Ith)/Ith;
plot (k, E(k))
end
I don't find out how create a plot with E(k) in terms of k, for k=1 to 10 in just one plot, so 10 points as the result. Thanks

採用された回答

Ingrid
Ingrid 2015 年 11 月 25 日
you have to use the hold on command such that you are adding with plot to the current figure without overwriting your previous plots
figure
hold on
  1 件のコメント
Julien B
Julien B 2015 年 11 月 25 日
編集済み: Julien B 2015 年 11 月 25 日
Right, thank you very much!

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

その他の回答 (0 件)

カテゴリ

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