How to extract rows based on a particular column values in a matrix?

25 次查看(过去 30 天)
I have attached a .mat file. It has two columns. In the second column if the values are greater than equal to 1 or if the values are less than equal to -1 the code will take the complete row and I'll get a new matrix. How to do it

采纳的回答

Subhadeep Koley
Subhadeep Koley 2020-11-9
load 'D.mat';
D_new = D((D(:, 2) >= 1) | (D(:, 2) <= -1), :);

更多回答(1 个)

KSSV
KSSV 2020-11-9
load D.mat ;
A = D(D(:,2)>=1,:) ;
B = D(D(:,2)<=-1,:) ;

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by