Finding and deleting negative values

9 vues (au cours des 30 derniers jours)
Nellikin
Nellikin le 14 Fév 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?

Réponse acceptée

Nellikin
Nellikin le 14 Fév 2012
found it: vi(vi<=0)=[];

Plus de réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by