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

조회 수: 23 (최근 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