Finding and deleting negative values

9 visualizaciones (últimos 30 días)
Nellikin
Nellikin el 14 de Feb. de 2012
I'm having trouble deleting negative values from a vector (vi) I wish to as an index:
vi =[-14:1:16];
I wrote this script:
l=length(vi); for i=1:l; while vi(i)<1; vi(i)=[]; break end end
Somehow, this only deletes the non-positive even numbered values in the matrix, not the negative ones (i.e. -14, -12, -10... disappear, but not -13, -11, -9)
Does anybody know why and can fix it for me?

Respuesta aceptada

Nellikin
Nellikin el 14 de Feb. de 2012
found it: vi(vi<=0)=[];

Más respuestas (0)

Categorías

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