How can i retrieve only the indices of elements within a matrix subset?
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a large matrix, C, and a matrix subset, Csub. I want to find the indices of the elements of Csub in C. So essentially, where Csub is in C. I get close with "intersect" but the problem is that I only want the indices of Csub in C, and intersect returns the indices of any element in C who's value is also found in Csub. Is there a way to restrict "intersect" to only the indices that directly correspond to the boundaries (not sure if that's the correct word) of Csub?
For example, if I have the following 2x5 matrix:
C = [1,2,3,4,5;1,2,3,4,3]
And the subset Csub corresponds to elements with linear indices 5 and 6, what is a way to retrieve these indices without also retrieving the index that lies outside of the subset (element with a value of 3 as well, with linear index of 10 in this case)?
1 个评论
Rik
2017-6-14
You could use a convolution and search for values that are exactly 1. Due to rounding that might not work for very large subsets, but in cases like your example it should work.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!