plot(r(i),z(n+1), '-b'); does not plot any points but plot(r(i),z(n+1), '.b'); does. I cannot figure it out why. Can anyone here help me regarding this?

 採用された回答

Walter Roberson
Walter Roberson 2023 年 9 月 14 日

0 投票

plot() by default does not draw any markers.
plot() only creates lines when there are two or more adjacent finite points.
plot(r(i),z(n+1), '-b');
cannot create a line because it only has a single point. Or you could think of it as producing a line of size zero. And it doesn't create a marker because you did not ask for a marker.
plot(r(i),z(n+1), '.b');
asks for a marker (but not for a line). When you specify a marker then by default lines are turned off. If you wanted both you need to ask for both, such as
plot(r, z, '-.b')
Much of the time you should avoid plotting each point as it is calculated, and instead store the values and plot() after the end of the loop.

3 件のコメント

Santanu
Santanu 2023 年 9 月 15 日
Thank you for your comments. Actually this runs under a loop parametrized by i and n with "hold on" and "hold off'. Even using "plot(r, z, '-.b')" does not work. Any help would be appreciated.
Voss
Voss 2023 年 9 月 15 日
plot(r, z, '.-b')
Santanu
Santanu 2023 年 9 月 15 日
編集済み: Santanu 2023 年 9 月 15 日
Thank you @Voss. It worked by changing that a bit(keeping it out of the loop).

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2023a

タグ

質問済み:

2023 年 9 月 14 日

編集済み:

2023 年 9 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by