How to adjust matrix

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?

Respuestas (1)

Walter Roberson
Walter Roberson el 12 de Dic. de 2022

0 votos

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 comentario

Voss
Voss el 13 de Dic. de 2022
Or delete all indices at once:
B = A;
B(:,[1 2 11 12]) = [];
B([1 2 11 12],:) = [];

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 12 de Dic. de 2022

Comentada:

el 13 de Dic. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by