hello I have a matrix n*n dimension, and I have a vector of indices for example ind=[3,4,6], I'd like to extract from the big matrix a small matrix formed by columns 3,4,6 and lines 3,4,6. In Matlab, if I have a matrix k(6*6), if I do k(3:6,3:6) I will obtain from lines 3 to 6 and from columns 3 to 6, but I just want lines 3,4,6 without line 5, and columns 3,4,6 without column 5.

1 comentario

bassima atra
bassima atra el 9 de Dic. de 2016
It is k(ind,ind) where ind is a vector of indices. I've tried it. thank u all.

Iniciar sesión para comentar.

 Respuesta aceptada

Image Analyst
Image Analyst el 9 de Dic. de 2016
Try
outputMatrix = inputMatrix(ind, ind);

Más respuestas (1)

John D'Errico
John D'Errico el 9 de Dic. de 2016
Editada: John D'Errico el 9 de Dic. de 2016
k([3 4 6],[3 4 6])
Or,
k(ind,ind)
3:6 is just a way of describing the numbers in the vector [3 4 5 6], i.e., one way of creating that vector. It does not mean that ALL indexing MUST be done using colon notation.

Categorías

Etiquetas

Preguntada:

el 9 de Dic. de 2016

Editada:

el 9 de Dic. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by