I want to erase following data when data goes down under 28.
For example,
If I have this matrix
36 33 31 29 30 27 31 33 24,
I want to make the matrix into
36 33 31 29 30 NaN NaN NaN NaN.
--> when I first met a number under 28, following datas are erased like this.
Thanks.

 채택된 답변

Walter Roberson
Walter Roberson 2021년 3월 9일

1 개 추천

x(find(x<28,1):end) = nan ;
or
x(~cumprod(x>=28)) = nan;

댓글 수: 2

Mehmed Saad
Mehmed Saad 2021년 3월 9일
oops i posted the same answer without looking
HyoJae Lee
HyoJae Lee 2021년 3월 9일
Thanks for helping.
This is the one that I want to find.
Appreciated!

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

추가 답변 (1개)

Mehmed Saad
Mehmed Saad 2021년 3월 9일

1 개 추천

you can use find but not recommended
x = [36 33 31 29 30 27 31 33 24];
x(find(x<28,1):end) = nan
x =
36 33 31 29 30 NaN NaN NaN NaN

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

태그

질문:

2021년 3월 9일

댓글:

2021년 3월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by