How can make code to present this following case?

I am doing my research. I have problem to make code to present this following matrices.
A=[ 1 2 3 4;
3 2 1 4]
And i have this following matrices to present value in matrices A.
value=1,
A(1)=[1 1 1;
1 1 1]
value=2,
A(2)=[2 2 2;
2 2 2]
value=3,
A(3)=[3 3 3;
4 4 4]
value=4,
A(4)=[4 4 4;
3 3 3]
So that I will get this following matrices
Res=[1 1 1 2 2 2 3 3 3 4 4 4;
1 1 1 2 2 2 4 4 4 3 3 3;
3 3 3 2 2 2 1 1 1 4 4 4;
4 4 4 2 2 2 1 1 1 3 3 3]
Thanks for your help.

 채택된 답변

Honglei Chen
Honglei Chen 2012년 9월 6일
편집: Honglei Chen 2012년 9월 6일

0 개 추천

A = [1 2 3 4;3 2 1 4]
B{1} = [1 1 1;1 1 1];
B{2} = [2 2 2;2 2 2];
B{3} = [3 3 3;4 4 4];
B{4} = [4 4 4;3 3 3];
Res = cell2mat(B(A))

댓글 수: 3

Febri
Febri 2012년 9월 6일
Sorry, it is not my desire. I want the result like res matrices.
I see, you want the A as the indices to construct Res. I've updated the answer.
Febri
Febri 2012년 9월 6일
yes, thanks you so much Mr.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2012년 9월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by