Square Matrix multiplication for n-number function handles

조회 수: 1 (최근 30일)
Georgios Koutsakis
Georgios Koutsakis 2019년 10월 4일
답변: SaiDileep Kola 2021년 3월 26일
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