开发者

How to compute the quadratic form of 2 matrix in matlab?

开发者 https://www.devze.com 2023-02-23 00:45 出处:网络
Given 2 matrix A, B with the same dimension, M(x, y) = |开发者_StackOverflowA(x, y).*A(x, y)A(x, y).*B(x, y)|

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])
0

精彩评论

暂无评论...
验证码 换一张
取 消