how to omit zero values while plotting the graph

251 ビュー (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2018 年 4 月 6 日
コメント済み: Ayman Ahmed 2021 年 8 月 5 日
could anyone tell me how to omit zero values while plotting the graph.

回答 (1 件)

dpb
dpb 2018 年 4 月 6 日
編集済み: dpb 2018 年 4 月 6 日
A)
yplot=y; % make a copy of the data specifically for plotting
yplot(yplot==0)=nan; % replace 0 elements with NaN
plot(x,yplot)
will return broken lines between locations which contain zero in yplot
B)
isNZ=(~y==0); % addressing logical array of nonzero elements
plot(x(isNZ),y(isNZ)) % plot only the subset
will be solid line just without those points that were zero
  1 件のコメント
Ayman Ahmed
Ayman Ahmed 2021 年 8 月 5 日
Many thanks. I was struggling with something like this but this code helped me too much

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

カテゴリ

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