Filter löschen
Filter löschen

How do I multiply two variables of form A(:,:, i) and B(:,:,i) where i = 20

2 Ansichten (letzte 30 Tage)
Sagar  Saxena
Sagar Saxena am 16 Mär. 2018
Kommentiert: Jan am 20 Mär. 2018
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 Kommentare
Sagar  Saxena
Sagar Saxena am 16 Mär. 2018
Could you plese help me to formulate this equation in matlab, rest I can figure out. Please see the attached image. I am just trying to plot the point spread function.
Jan
Jan am 20 Mär. 2018
In this formula you multiply with the squared norm of Phi, which is a scalar, not a matrix.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Prajit T R
Prajit T R am 19 Mär. 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 Kommentar
Jan
Jan am 20 Mär. 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by