Given 2 matrix A, B with the same dimension,
M(x, y) = |开发者_StackOverflowA(x, y).*A(x, y) A(x, y).*B(x, y)|
|A(x, y).*B(x, y) B(x, y).*B(x, y)|
How to get the M in matlab?
updated
Hopefully, we can get a M with dimension (m, n, 2, 2).
Well, this is a straightforward way to do it:
M = [ A.*A A.*B ; A.*B B.*B ]
Or did you have something more optimized in mind?
[Edit] If I understand correctly, you want a 4D result. Here is my ugly solution:
M = reshape([A(:).*A(:) ; A(:).*B(:) ; A(:).*B(:) ; B(:).*B(:)], [size(A) 2 2])
精彩评论