Multiplying Matrices within same Cell Array

4 ビュー (過去 30 日間)
Nick S
Nick S 2016 年 2 月 20 日
コメント済み: Nick S 2016 年 2 月 20 日
Hi
I have a code where I generate a set number of matrices in a cell array with a for loop based on an input n. I want to know how to multiply the matrices together once the loop is complete.
Sample code with irrelevant info removed, based on input integer n:
A=cell(n,1);
index=0;
for Amatrix=1:n;
index=index+1;
A{index}=[4x4 Amatrix info];
end
So if the input is n = 3, A will equal a 3x1 array with a different 4x4 double matrix in the 1st, 2nd and 3rd rows. How do I multiply A{1}*A{2}*A{3} (where this procedure could be for any value of n: A{1}*A{2}*...*A{n}) to create one final 4x4 matrix?
Thanks!

採用された回答

Walter Roberson
Walter Roberson 2016 年 2 月 20 日
Amult = A{1};
for index = 2 : n
Amult = Amult * A{index};
end
  1 件のコメント
Nick S
Nick S 2016 年 2 月 20 日
Thanks! That works!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by