Can I make the plot skip jumps in data?

I have a plot of data, where the y values are bounded from -pi to pi. After a value goes above pi, it starts at the bottom of the plot with a value of pi. However, when plotted this means there is a line connecting the jump in value. Is there a way to plot the data without the lines connecting the values at each jump point?

2 件のコメント

Walter Roberson
Walter Roberson 2021 年 4 月 17 日
OG
OG 2021 年 4 月 18 日
That tries to fix the discontinuity by moving the data set by factors of 2pi. I want the discontinuities to stay, just without the line connecting them.

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

 採用された回答

Atsushi Ueno
Atsushi Ueno 2021 年 4 月 18 日

0 投票

The idea is replacing discontinus part by NaN values.
x = 1:0.1:pi*10;
y = mod(x,pi*2)-pi;
y(abs(diff(y))>2) = NaN;
plot(x,y);

1 件のコメント

OG
OG 2021 年 4 月 18 日
Thanks, this seems to do what I want!

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2020b

タグ

質問済み:

OG
2021 年 4 月 17 日

コメント済み:

OG
2021 年 4 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by