Borrar filtros
Borrar filtros

how delete all the negative values

18 visualizaciones (últimos 30 días)
karthik suresh
karthik suresh el 8 de Nov. de 2016
Respondida: Thorsten el 8 de Nov. de 2016
i have vector with positive values and negative for eg
-0.26476
-0.27643
-0.24648
+0.02679
+0.0546
-0.2000
+0.5545
+....
+.....
i would like to delete all the values until the last negative value
k_2 = find(removing <= 0);
s_u(k_2)=[];
it selectively deletes all the negative values.
and when i use
k_2 = find(removing <= 0);
s_u(1:k_2)=[];
it does nothing
thank you

Respuesta aceptada

Thorsten
Thorsten el 8 de Nov. de 2016
x = x(find(x < 0, 1, 'last'):end);

Más respuestas (0)

Categorías

Más información sobre NaNs 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