필터 지우기
필터 지우기

Finding specific values from a large matrix

조회 수: 5 (최근 30일)
Meghan
Meghan 2016년 8월 24일
댓글: Star Strider 2016년 8월 24일
Hi
So I have a two matrices of 46878x1. On the first matrix I used inpolygon, which resulted in 18 points being identified. What I need to do is extract the corresponding values from the second matrix, D.
Anyone have any suggestions? I've tried using ismember but it hasn't worked because I'm not comparing equal values. The first matrix has ID points, while the second matrix has point values.
Thanks Meghan :)

채택된 답변

Star Strider
Star Strider 2016년 8월 24일
The inpolygon function returns a logical array, so you need to use it to define the values in vector ‘A’ in order to match them to the elements in vector ‘B’.
I would do something like this:
inA = inpolygon(A, 1, xv, 1); % Guessing Your Code
inB = ismember(B,A(inA)); % Guessing Your Code
The ‘inB’ vector is a logical vector showing the locations in vector ‘B’ that are in the subset of ‘A’ addressed by logical vector ‘inA’.
Yours is certainly an novel way to use the inpolygon function. I’ll keep that in mind.
  댓글 수: 2
Meghan
Meghan 2016년 8월 24일
Thanks for your help. Turns out I was a bit of a fool and it was as simple as b=d(in). Didn't think it would be that simple! I also didn't explain myself very well in the question so that you for trying to help :)
Star Strider
Star Strider 2016년 8월 24일
My pleasure.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by