필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Stephanie Diaz
Stephanie Diaz 2017년 6월 14일
댓글: Rik 2017년 6월 14일
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
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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by