extracting matrix from a given one
Mostra commenti meno recenti
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 Commento
bassima atra
il 9 Dic 2016
Risposta accettata
Più risposte (1)
John D'Errico
il 9 Dic 2016
Modificato: John D'Errico
il 9 Dic 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 Commento
bassima atra
il 9 Dic 2016
Categorie
Scopri di più su Matrix Indexing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!