How to multiply function handles stored in a cell array?
2 次查看(过去 30 天)
显示 更早的评论
I have a application to multiply the function handles which are stored in a cell array.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/696034/image.png)
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,
D=length(Na);
A=[1 0;0 1];
for j=1:D
sa=@(w) A*Na{1,j}(w);
A=@(w) sa(w);
end
It is not producing any results.
Kindly provide any suggestions.
0 个评论
采纳的回答
Rik
2021-7-27
Na=repmat({@(w) [1,-w*i(2,e);0 1]},1,3)
sa=@(w) 1;
for n=1:numel(Na)
sa=@(w) sa(w)*Na{n}(w);
end
Note that in this case you can do something much simpler:
N=3;
sa=@(w) [1,-w*i(2,e);0 1]^N;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!