MATLAB Answers

How to multiply function handles stored in a cell array?

3 ビュー (過去 30 日間)
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021 年 7 月 27 日
I have a application to multiply the function handles which are stored in a cell array.
The expected output need to be,
sa=@(w) Na{1,1}(w)*Na{1,2}(w)*Na{1,3}(w);
The length of the cell array differs for each case. So, the multiplication need to be automated.
I have tried with the below script,
A=[1 0;0 1];
for j=1:D
sa=@(w) A*Na{1,j}(w);
A=@(w) sa(w);
It is not producing any results.
Kindly provide any suggestions.


Rik 2021 年 7 月 27 日
Na=repmat({@(w) [1,-w*i(2,e);0 1]},1,3)
Na = 1×3 cell array
{@(w)[1,-w*i(2,e);0,1]} {@(w)[1,-w*i(2,e);0,1]} {@(w)[1,-w*i(2,e);0,1]}
sa=@(w) 1;
for n=1:numel(Na)
sa=@(w) sa(w)*Na{n}(w);
Note that in this case you can do something much simpler:
sa=@(w) [1,-w*i(2,e);0 1]^N;
  1 件のコメント
Vinothkumar Sethurasu
Vinothkumar Sethurasu 2021 年 7 月 28 日
Thank you.


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by