Delete rows from an array with values from multiple columns with the same condition

7 Ansichten (letzte 30 Tage)
I have a 39801x7 array. I want to keep any row of data where is there is a value less than -5 or greater than 5 that the row of data will be kept. I have done the code below but it only does it for column 7 and not all columns. I would like to know what I am doing wrong.
a is the 39801x7 array
for i = 1:7
A1 = a(a(:,i) <= -5 | a(:,i) >= 5 , :);
end

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 23 Feb. 2019
mask = any(a <= -5 | a >= 5, 2);
A1 = a(mask,:);

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by