I have an ordered pair matrix, A=[x y], and a layered matrix, N, with three layers. What I want to do is search layer 2 for the correct x value and then layer 3 for the corresponding y value. Layer 2 represents the x axis and layer 3 represents the y axis. So in essence, I want to scan layer 2 and highlight the column that contains the x value and then scan the 3rd layer, highlight the row that contains the y value, and return the index at which layer 2 and layer 3 intersect. Any ideas on how to do this? I showed my setup of the layered matrix N and the values in matrix A. Layer 1 of matrix N are just random values and are irrelevant for this problem. Printing out layer 2 and 3 of matrix N would help visualize what I am talking about. Thanks!
cn = 3;N11 = randi([0,5],cn,cn);N12 = randi([1,4],cn,cn);N13 = randi([0,7],cn,cn);N14 = randi([0,6],cn,cn);N21 = randi([1,3],cn,cn);N22 = randi([1,7],cn,cn);N23 = randi([4,6],cn,cn);N24 = randi([2,7],cn,cn);N31 = randi([1,4],cn,cn);N32 = randi([6,7],cn,cn);N33 = randi([1,7],cn,cn);N34 = randi([3,4],cn,cn);N41 = randi([2,5],cn,cn);N42 = randi([0,3],cn,cn);N43 = randi([5,6],cn,cn);N44 = randi([0,4],cn,cn); N = [N11 N12 N13 N14; N21 N22 N23 N24; N31 N32 N33 N34; N41 N42 N43 N44];[x, y] = size(N);H1 = -x/2:1:x/2;H2 = H1(find(H1~=0));V1 = -y/2:1:y/2;V2 = V1';V3 = V2(find(V2~=0));N(:,:,2) = H2(ones(x,1),:);N(:,:,3) = V3(:,ones(y,1)) % finish making layered matrix, N
A = [-6 -1; -3 4; 2 2; 5 -1];
Best Answer