필터 지우기
필터 지우기

plot and ignore certain values

조회 수: 59 (최근 30일)
David C
David C 2012년 4월 24일
댓글: Samuel Bartlett 2018년 5월 14일
I have a vector I need to plot that contains numerics gathered from a data acquisition board collecting at 1 hz (1 point / sec).
any time signal is lost, a placeholder "-1" value is used in that cell and I need to plot this vector but not have it plot the "-1"s
is the plot function capable of such a task? or do I have to remove all the "-1"s first?
  댓글 수: 1
Nathaniel Menefee
Nathaniel Menefee 2017년 3월 10일
So i want to do that same thing but i want to do it with 2 different plots. is there any way to do this.

댓글을 달려면 로그인하십시오.

채택된 답변

Wayne King
Wayne King 2012년 4월 25일
You can set those values to NaN
x(x == -1) = NaN;
plot(x)
They will show up as gaps in your plot.
  댓글 수: 2
David C
David C 2012년 4월 25일
bingo, logical indexing saves the day! Thanks Wayne!
Samuel Bartlett
Samuel Bartlett 2018년 5월 14일
THANK YOU SO MUCH!!! This saved my life!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Wayne King
Wayne King 2012년 4월 24일
You can just plot x for x~= -1 or did you mean that the character array "-1" is entered? Not sure what you mean by the " ".
x = randi([-1 4],20,1);
plot(x(x~= -1))
  댓글 수: 1
David C
David C 2012년 4월 24일
almost did the trick
your code stitched the gaps together for the areas where -1 was present, but I would like for it to leave the gaps present!
Thank you!

댓글을 달려면 로그인하십시오.

카테고리

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