I have a 21x21 matrix. I want to remove the first two colums and rows, and the 11th and 12th columns and rows (resulting in a 17x17 matrix). How should I do this?

답변 (1개)

Walter Roberson
Walter Roberson 2022년 12월 12일

0 개 추천

tokeep = [3:10, 13:21];
B = A(tokeep, tokeep);
or
B = A;
B(:,11:12) = []; B(11:12,[]) = [];
B(1:2,:) = []; B(:,1:2) = [];
Always delete the higher-index before the lower index.

댓글 수: 1

Voss
Voss 2022년 12월 13일
Or delete all indices at once:
B = A;
B(:,[1 2 11 12]) = [];
B([1 2 11 12],:) = [];

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2022년 12월 12일

댓글:

2022년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by