Multiply all pages of a matrix

1 回表示 (過去 30 日間)
souperman1985
souperman1985 2021 年 1 月 15 日
回答済み: Bruno Luong 2021 年 1 月 15 日
I have a 2x2xn matrix and I want to multiply all pages together. I know I can do it using a loop. Is there any way that does NOT require looping, however? Thanks!
aMat=reshape(1:20,[2,2,5])
bMat = aMat(:,:,1)*aMat(:,:,2)*aMat(:,:,3)*aMat(:,:,4)*aMat(:,:,5)
cMat = eye(2);
for i=1:size(aMat,3)
cMat = cMat*aMat(:,:,i);
end
cMat

採用された回答

Bruno Luong
Bruno Luong 2021 年 1 月 15 日
AFAIK there is no alternative way in general; unless your matrices has special property that can use some simplification.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by