how to omit zero values while plotting the graph
188 次查看(过去 30 天)
显示 更早的评论
could anyone tell me how to omit zero values while plotting the graph.
0 个评论
回答(1 个)
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
2021-8-5
Many thanks. I was struggling with something like this but this code helped me too much
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!