extracting matrix from a given one
Mostrar comentarios más antiguos
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
el 9 de Dic. de 2016
Respuesta aceptada
Más respuestas (1)
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.
1 comentario
bassima atra
el 9 de Dic. de 2016
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!