MATLAB: Four indexing matrix

four indexing matrix

I have a matrix nxn, each element is described by a 2 index number (i.e. one number for the column, one for the row). The problem is that i want to access this matrix by a four digit indexing. Is there a way to do that?

Best Answer

Ok, i made it. So, for a given matrix "pall" i go to a matrix "alpha(i,j,k,l)". For example: alpha(1,1,1,1)=pall(1,1)=1 alpha(2,2,2,2)=pall(4,4)=16 alpha(1,1,1,2)=pall(1,2)=2 .. p.s. If you have a faster solution please tell me. Thank you all
%this is the actual algorithm % pall=([1 2 3 4;5 6 7 8; 9 10 11 12; 13 14 15 16]); k=0 for n1=1:4 for n2=1:4 k=k+1 temp(k)=pall(n1,n2) end end k=0 alpha=zeros(2,2,2,2) for n3=1:2 for n4=1:2 for n5=1:2 for n6=1:2 k=k+1 alpha(n3,n4,n5,n6)=temp(k) end end end end %