Monday, 15 September 2014

Deleting rows containing any number outside a specific range - MATLAB -



Deleting rows containing any number outside a specific range - MATLAB -

what best way delete rows of matrix containing number outside specific range? example

a = 200 400 500 200 500 100 600 200 200 100 300 200 range = [200 500];

rows 3,4 , 5 deleted contain numbers <200 , >500.

this should work -

a(any(a<200 | a>500,2),:)=[];

to state -

range1 = [200 500]; %// changed variable name %// range builtin function name a(any(a<range1(1) | a>range1(2),2),:)=[];

if number of rows deleted lot, performance might index other rows instead of deleting -

range1 = [200 500]; = a(~any(a<range1(1) | a>range1(2),2),:)

matlab

No comments:

Post a Comment