How do I erase following data?

2 visualizaciones (últimos 30 días)
HyoJae Lee
HyoJae Lee el 9 de Mzo. de 2021
Comentada: HyoJae Lee el 9 de Mzo. de 2021
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 9 de Mzo. de 2021
x(find(x<28,1):end) = nan ;
or
x(~cumprod(x>=28)) = nan;
  2 comentarios
Mehmed Saad
Mehmed Saad el 9 de Mzo. de 2021
oops i posted the same answer without looking
HyoJae Lee
HyoJae Lee el 9 de Mzo. de 2021
Thanks for helping.
This is the one that I want to find.
Appreciated!

Iniciar sesión para comentar.

Más respuestas (1)

Mehmed Saad
Mehmed Saad el 9 de Mzo. de 2021
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

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by