matrix multiplcation in loop

3 ビュー (過去 30 日間)
Daniel
Daniel 2022 年 10 月 15 日
回答済み: Bruno Luong 2022 年 10 月 15 日
Hi-
I have 2 2x2 matices and want to multiple every element in one matix by the other and get 4 dimnesions. For example, I have A=[2 3; 4 5] and B=[3 4; 5 6]. The answer for X should be X(:,:,1)=[6 8;10 12], X(:,:,2)=[9 12;15 18], X(:,:,3)=[12 16; 20 24], X(:,:,1)=[15 20; 25 30]. I hope I explained that well. Thanks for any help.

採用された回答

Bruno Luong
Bruno Luong 2022 年 10 月 15 日
X is three dmiensions nit 4 as you wrote
A=[2 3; 4 5];
B=[3 4; 5 6];
X = B .* reshape(A.', 1,1,[])
X =
X(:,:,1) = 6 8 10 12 X(:,:,2) = 9 12 15 18 X(:,:,3) = 12 16 20 24 X(:,:,4) = 15 20 25 30

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by