Azzera filtri
Azzera filtri

Matrix multiplication and trace can any body help me

1 visualizzazione (ultimi 30 giorni)
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,

Risposte (1)

Matt J
Matt J il 24 Ago 2020
Modificato: Matt J il 24 Ago 2020
result=sum( A.'.*sum(B,3) ,'all')

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by