Matrix multiplication and trace can any body help me

1 次查看(过去 30 天)
Hi,
I have a A(5X5) matrix and a B(5X5X10) matrix. I want to compute Trace(A*B(:,:,1))+Trace(A*B(:,:,2)) +…+Trace(A*B(:,:,10))
Any direct/efficient way of doing this without the for loop?
Thank you very much,

回答(1 个)

Matt J
Matt J 2020-8-24
编辑:Matt J 2020-8-24
result=sum( A.'.*sum(B,3) ,'all')

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by