A=[1 2 3 4 5 6;
0 0 1 1 0 1;
0 0 1 0 1 0]
Sum of second and third row if equal to zero, then in new matrix that column is to be excluded. So, the result shall be
A=[3 4 5 6;
1 1 0 1;
1 0 1 0]

 채택된 답변

the cyclist
the cyclist 2017년 1월 24일
편집: the cyclist 2017년 1월 24일

1 개 추천

colToRemove = sum(A(2:end,:))==0;
A(:,colToRemove) = [];

댓글 수: 1

the cyclist
the cyclist 2017년 1월 24일
Edited my answer so that it will sum all rows except the first one.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Roger Stafford
Roger Stafford 2017년 1월 24일

1 개 추천

A = A(:,(A(2,:)+A(3,:)~=0));

댓글 수: 1

Vishal Sharma
Vishal Sharma 2017년 1월 24일
Thanks Roger Stafford,,, if there are n rows, please also suggest answer...

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2017년 1월 24일

답변:

2017년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by