Clear Filters
Clear Filters

Square Matrix multiplication for n-number function handles

1 view (last 30 days)
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);
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};
George Koutsakis

Answers (1)

SaiDileep Kola
SaiDileep Kola on 26 Mar 2021
Check solution proposed for similar question here


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!