Double sum - vector (matrix) solution
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi!
I want to calculate the expression
, where C and F - matrix (n x m). How can I do it without loops?
Thank you for your answers!
0 Commenti
Risposta accettata
James Tursa
il 30 Nov 2020
Modificato: James Tursa
il 30 Nov 2020
result = sum(C(:).*F(:));
or for later versions of MATLAB
result = sum(C.*F,'all');
This all assumes that the actual indexing starts at 1, not 0 as your formula above is written, since MATLAB uses 1-based indexing.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing 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!