Filter löschen
Filter löschen

How can i retrieve only the indices of elements within a matrix subset?

2 Ansichten (letzte 30 Tage)
Stephanie Diaz
Stephanie Diaz am 14 Jun. 2017
Kommentiert: Rik am 14 Jun. 2017
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 Kommentar
Rik
Rik am 14 Jun. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by