Filter löschen
Filter löschen

Matrix multiplication and trace can any body help me

1 Ansicht (letzte 30 Tage)
vikas Kumar
vikas Kumar am 24 Aug. 2020
Bearbeitet: Matt J am 24 Aug. 2020
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,

Antworten (1)

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

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by