How do I multiply two variables of form A(:,:, i) and B(:,:,i) where i = 20
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2018-3-20
In this formula you multiply with the squared norm of Phi, which is a scalar, not a matrix.
采纳的回答
Prajit T R
2018-3-19
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 个评论
Jan
2018-3-20
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.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!