Problem with plotting dots in points

Hi,
I have problem I wanted to plot dots in points but It shows only last dot
figure(2);
A = [1,2,3,4,5,6,7,8]
Y = [1,2,3,4,5,6,7,8]
i = 8;
for c = 1:i
hold on
plot(A(i),Y(i),'r.')
end

回答 (1 件)

Jan
Jan 2022 年 3 月 17 日
編集済み: Jan 2022 年 3 月 17 日

0 投票

The loop does not depend on the loop counter:
i = 8; % <- this is the index in all iterations
for c = 1:8
I assume you mean:
for i = 1:8

2 件のコメント

Thomas Wans
Thomas Wans 2022 年 3 月 17 日
Yes, but it still shows only last dot
Jan
Jan 2022 年 3 月 18 日
編集済み: Jan 2022 年 3 月 18 日
Nope. This works:
figure;
A = [1,2,3,4,5,6,7,8];
Y = [1,2,3,4,5,6,7,8];
for i = 1:8
hold on
plot(A(i),Y(i),'r.')
end

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

製品

リリース

R2021b

タグ

質問済み:

2022 年 3 月 17 日

編集済み:

Jan
2022 年 3 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by