How to adjust matrix

5 Ansichten (letzte 30 Tage)
Sharanya
Sharanya am 12 Dez. 2022
Kommentiert: Voss am 13 Dez. 2022
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?

Antworten (1)

Walter Roberson
Walter Roberson am 12 Dez. 2022
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 Kommentar
Voss
Voss am 13 Dez. 2022
Or delete all indices at once:
B = A;
B(:,[1 2 11 12]) = [];
B([1 2 11 12],:) = [];

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by