How can I clear columns and rows of a matrix?

조회 수: 1 (최근 30일)
Ayob
Ayob 2014년 1월 19일
편집: Ayob 2014년 1월 19일
I have matrix like A which is in a square form p*p and a line matrix B in a form of q*1 (q<p).
I want to clear rows and columns of matrix A with the help of B. for example:
A=[1 2 3 4;5 6 7 8;9 10 11 12;1 2 3 4]
and
B=[2 4]
I should eliminate second row and column 'As B(1)=2' and fourth row and column 'As B(2)=4'.
So A becomes [1 3;9 11].

채택된 답변

Amit
Amit 2014년 1월 19일
편집: Amit 2014년 1월 19일
A(B,:) = [];
A(:,B) = [];
  댓글 수: 2
Ayob
Ayob 2014년 1월 19일
편집: Ayob 2014년 1월 19일
I check it,but didn't work .
??? Subscripted assignment dimension mismatch.
Amit
Amit 2014년 1월 19일
I edited it and tested it. It works.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by