필터 지우기
필터 지우기

How to find the value of a matrix in a specific position?

조회 수: 1 (최근 30일)
abbxucy11
abbxucy11 2016년 9월 13일
편집: Stephen23 2016년 9월 13일
I have a matrix A with the positions (361x2) stored and i want to find the values of another matrix B in the specific positions ..how can i do it?
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2016년 9월 13일
please show example
abbxucy11
abbxucy11 2016년 9월 13일
I have this code here and i found the location of all the values from -180 to 180 and stored them using the save command. It saves the locations in a function named find_results that is a matrix 361x2.
or=flow.Orientation; ordeg=(180*or)/pi; ORIENT=round(ordeg)
for a= 180:-1:-180
[i,j]=find(ORIENT==a)
end
save('test.mat','i','j')
Then, i have another matrix named magnitude and i want to find the values of each location that there is in the find_results matrix

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

채택된 답변

Adam
Adam 2016년 9월 13일
sz = size( B );
idx = sub2ind( sz, A(:,1), A(:,2) );
res = B( idx );

추가 답변 (1개)

Stephen23
Stephen23 2016년 9월 13일
편집: Stephen23 2016년 9월 13일
You can use sub2ind:
idx = sub2ind(size(B), A(:,1), A(:,2));
out = B(idx);

카테고리

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