MATLAB: Combining two separate arrays into singular payoff matrix

arraycombiningMATLAB

Hi everyone,
I have two separate arrays that I am hoping to combine into a singular payoff matrix. Does anyone have any tips for doing so?
Right now, I have two 2×2 arrays that look like:
A = [4 2,
2 0]
B = [4 2,
4 2]
Instead of having them be separate, I want to combine them into a singular 2×2 payoff matrix P with the end result looking like:
P = [(4,4) (2,2),
(2,4) (0,2)]
I want to avoid manually typing in cell values and am looking for some way to achieve the end result by combining the existing A and B arrays. I would appreciate any help. Thank you!

Best Answer

P = reshape(num2cell([A(:), B(:)], 2), [], size(A, 2));
celldisp(P)