How do I multiply two variables of form A(:,:, i) and B(:,:,i) where i = 20
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
SO basically , I need the product of these 2 variables for 20 iterations and then add the products. I tried using * and .* but that doesn't work.
3 Commenti
Jan
il 20 Mar 2018
In this formula you multiply with the squared norm of Phi, which is a scalar, not a matrix.
Risposta accettata
Prajit T R
il 19 Mar 2018
Hi Sagar
Try this code:
sum=0
for i=1:20
sum=sum+s(:,:,i).*(phi(:,:,i).^2)
end
It will work if the sizes of A and B match.
Cheers
1 Commento
Jan
il 20 Mar 2018
Using "sum" as variable causes troubles frequently, because the builtin function sum() is not available afterwards. Better avoid shadowing of builtin functions by using different names.
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Logical 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!