Square Matrix multiplication for n-number function handles

1 次查看(过去 30 天)
Hello,
The picture attached defines cleary the proposed problem.
TransferMatrixperLayer{1,1} = @(s,i) s+i;
TransferMatrixperLayer{1,2} = @(s,i) s+2*i;
TransferMatrixperLayer{2,1} = @(s,i) s+3*i;
TransferMatrixperLayer{2,2} = @(s,i) s+4*i;
The TransferMatrixperLayer is a cell array 2x2 function handle. The i defines the number of each individual TransferMatrixperLayer and s is the function argument. I would like to multiply any number of 2x2 matrices and result to an overall 2x2 matrix where is it going to be a function handle of s.
Long story short: How to do a matrix multiplication of a 2x2 function handle (as a function of s) matrix for i=1:N where for example N=3.
Tried to do it like the proposed method, but it doesn't work.
% This part of the code doesn't work.
TransferMatrix=@(s) TransferMatrixperLayer(s,1);
for i = 2:N
TransferMatrix=@(s) TransferMatrix(s) .* TransferMatrixperLayer(s,i);
end
The following is expected to be the final result.
A=@(s) TransferMatrix{1,1};
B=@(s) TransferMatrix{1,2};
C=@(s) TransferMatrix{2,1};
D=@(s) TransferMatrix{2,2};
Thanks,
George Koutsakis

回答(1 个)

SaiDileep Kola
SaiDileep Kola 2021-3-26
Check solution proposed for similar question here

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by