Info
This question is closed. Reopen it to edit or answer.
How to multiply a (2 by 2) matrix M with M [i.e M*M'] where the elements of the matrix M are also matrices ?
1 view (last 30 days)
Show older comments
%Here is my problem. Which can be directly copied in Matlab.
clc;
x=1:5;
y=6:10;
[x,y]=meshgrid(x,y);% i.e x and y are matrices.
%I have some coefficients
a1=0.2; a2=.5; a3=0.2; a4=0.4;
%Now the matrix is:
M=[a1.*x a2.*y; a3.*x a4.*y]
%How to get Newmatrix =M*M' ?
%The new matrix must have 4 submatrices in the form of M11 M12 M21 and M22?
%I did following:
M=[a1.*x a2.*y; a3.*x a4.*y];
A= M*M';
AA = mat2cell(A,repmat(5,2,1), repmat(5,2,1));
M11=cell2mat(AA(1))
M12=cell2mat(AA(3))
M21=cell2mat(AA(2))
M22=cell2mat(AA(4))
%However, these outputs are not correct. How to correct it? I suspect that the x and y when multiplied or squired should be element-wise (.i.e. x.^2 ) but I could not manage to do that in Matlab.
0 Comments
Answers (1)
Thorsten
on 4 Dec 2015
M={a1.*x, a2.*y; a3.*x, a4.*y};
A = cellfun(@(x) x*x', M, 'UniformOutput', false);
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!