Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Stephanie Diaz
Stephanie Diaz el 14 de Jun. de 2017
Comentada: Rik el 14 de Jun. de 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 comentario
Rik
Rik el 14 de Jun. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by