extracting matrix from a given one

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 个评论

It is k(ind,ind) where ind is a vector of indices. I've tried it. thank u all.

请先登录,再进行评论。

更多回答(1 个)

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.

类别

在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by