필터 지우기
필터 지우기

lookup table as a matrix instead of an array

조회 수: 3 (최근 30일)
Aravin
Aravin 2012년 8월 9일
I have a matrix square R which contains the relation ship (distances) between numbers. Elements in R is uint8 and the size is 256 x 256.
Let say I have two other matrix A and B of same size now. Now I want to generate Matrix C which is extracted from R. In other words, looking the values of A and B in R and putting them in C.
For example
C ( 5, 5 ) = R(A(5,5), B(5,5));
I can't do it using intlut as it is for any array. How can we do it if we have matrix ?

채택된 답변

Jan
Jan 2012년 8월 19일
See sub2ind.
index = sub2ind(size(R), A(:), B(:));
C = reshape(R(index), size(A));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by