How to adjust matrix
4 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
回答 (1 件)
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
2022 年 12 月 13 日
Or delete all indices at once:
B = A;
B(:,[1 2 11 12]) = [];
B([1 2 11 12],:) = [];
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!