how to graph using loop?
1 回表示 (過去 30 日間)
古いコメントを表示
I want to calculate a problem and graph it
I want to graph i and area but it only show one point on my graph
% question1
clear all
a = 1
vectori = []
areavec = []
figure;
for i = 0:20
a = a + a
area = a *(1/8).^i
scatter(i,area)
end
0 件のコメント
採用された回答
the cyclist
2020 年 11 月 21 日
編集済み: the cyclist
2020 年 11 月 21 日
Put the command
hold on
on the line after figure.
0 件のコメント
その他の回答 (1 件)
Setsuna Yuuki.
2020 年 11 月 21 日
編集済み: Setsuna Yuuki.
2020 年 11 月 21 日
You must change this:
clear all
a = 1
vectori = []% ??
areavec = []
figure;
for i = 0:20
a = a + a
areavec(i+1) = a *(1/8).^i %area --> areavec and areavec is a vector, not a scalar
end
i = 0:20;
scatter(i,areavec) %area --> areavec and graph must be out of cycle
4 件のコメント
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!