Find index to x,y pairs

조회 수: 4 (최근 30일)
K E
K E 2012년 6월 6일
I have two vectors xEdges and yEdges which define positions in the x,y plane. In the example below, the lower left location value would be (20, 2). Given a vector list of locations, how can I find their indices within xEdges,yEdges? In the example below, the indices corresponding to the desired locations xFind,yFind would be ix = [ 2 4 4 6 ], iy = [ 2 6 8 9 ]. I need to use the indices to look up values of a matrix which has size nY,nX.
xEdges = 2:11 ; yEdges = 20:28 ; % Location vector
xFind = [ 3 5 5 7 ] ; yFind = [ 21 25 27 28 ] ; % x, y pairs

채택된 답변

the cyclist
the cyclist 2012년 6월 6일
[xtf ix] = ismember(xFind,xEdges);
[ytf iy] = ismember(yFind,yEdges);
  댓글 수: 1
K E
K E 2012년 6월 7일
Perfect, thank so much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by