remove specific rows by referencing on the first digit of each row.

조회 수: 1 (최근 30일)
JL
JL 2019년 9월 9일
댓글: JL 2019년 9월 9일
Hi everyone, I want to reduce remove rows in matrix A, by referencing on the first number in each row to get B. In this case, if the first number is 1, remove the row
A = [1 1 1 0
0 1 1 1
0 1 1 0
1 0 1 0];
Results B =
B =[0 1 1 1
0 1 1 0];

채택된 답변

madhan ravi
madhan ravi 2019년 9월 9일
B = A(~A(:,1),:)

추가 답변 (1개)

Fabio Freschi
Fabio Freschi 2019년 9월 9일
index = 1;
% A(:,1) == index finds the rows with specific value (logical indexing)
B = A(A(:,1) == index,:)

카테고리

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