extracting matrix from a given one
Show older comments
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 Comment
bassima atra
on 9 Dec 2016
Accepted Answer
More Answers (1)
John D'Errico
on 9 Dec 2016
Edited: John D'Errico
on 9 Dec 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 Comment
bassima atra
on 9 Dec 2016
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!