multiplying multiple values inside multiple matrices
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have multiple matrices (all quite large, of equal size) that all need to be multiplied into a final matrix. For example, if I have a matrix [2, 2] and another [3, 2], I need to find a way to multiply these two to obtain [6, 4]. The trick being that each matrix value is multiplied by the corresponding value in the same location in all the other matrices.
Thanks
1 件のコメント
Azzi Abdelmalek
2013 年 9 月 24 日
編集済み: Azzi Abdelmalek
2013 年 9 月 24 日
If
A=[1 2;3 4]
B=[1 2;3 4;5 6]
What is the expected result?
採用された回答
Image Analyst
2013 年 9 月 24 日
Since they are all of the same size, and you want to multiply them element by element, you can simply dot multiply:
c1 = a .* b; % For only two matrices.
c2 = a .* b .* c .* d .* e; % for 5 matrices.
1 件のコメント
Image Analyst
2013 年 9 月 24 日
For your new question on means:
meanOf2 = (a + b) / 2; % Mean of two matrices.
meanOf5 = (a+b+c+d+e)/5; % Mean of 5 matrices.
その他の回答 (1 件)
Azzi Abdelmalek
2013 年 9 月 24 日
Maybe this is what you want
A=[1 2;3 4]
B=[1 2;3 4;5 6]
out=cell2mat(arrayfun(@(x) x*B,A,'un',0))
3 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!