Clear Filters
Clear Filters

Matrix multiplication and trace can any body help me

1 view (last 30 days)
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,

Answers (1)

Matt J
Matt J on 24 Aug 2020
Edited: Matt J on 24 Aug 2020
result=sum( A.'.*sum(B,3) ,'all')

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!