How to adjust matrix

3 次查看(过去 30 天)
Sharanya
Sharanya 2022-12-12
评论: Voss 2022-12-13
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
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],:) = [];

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by