MATLAB: If I have a 3d matrix(A), how can i check if a given 2d matrix(B) is one of matrix A’s pages

MATLABmatrix

I have a 3d matrix A, let say A is a 2x2x3 matrix as follows [1 2 ;3 4] [5 6;3 4] [5 6;1 2]
now I want to know if a 2×2 matrix like [5 6;3 4] is one of A's pages. so since [5 6;3 4] is the second page of A, I should get 1 as the answer.

Best Answer

Another approach:
A = cat(3, [1 2; 3 4], [5 6; 3 4], [5 6; 1 2])
B = [5 6; 3 4]
S = reshape(A, 1, []);
T = reshape(B, 1, []);
match = strfind(S, T);
Result = any(mod(match, 4) == 1);
This can be made a one-liner easily.