how to omit zero values while plotting the graph

조회 수: 80 (최근 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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by