Hi,. I need support in doing a double summation in MATLAB. Thank you.
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to do the following double summation ∑(i=0,2)∑(j=0,3)〖(2i+3j)〗in a MATLAB program. The answer should be 78. Thank you.
HD
采纳的回答
hani daniel
2017-4-28
1 个评论
Adam
2017-4-28
Please just accept the answer you are happy with. Don't add your own answer to just say which answer works and then accept that! You can add comments to people's answers.
更多回答(3 个)
Star Strider
2017-4-28
There are likely several ways to code this (I assume this is a coding exercise, since the correct answer is provided).
This is one approach:
i = 0:2;
j = 0:3;
[I,J] = meshgrid(i, j);
f = @(i,j) 2*i + 3*j; % Anonymous Function
fmtx = f(I,J);
Answer = sum(fmtx(:))
I am not documenting it, leaving it for you to understand how it works.
2 个评论
Star Strider
2017-4-28
hani daniel’s Answer is copied here:
Hi Star Strider,
Thank you for your answer.
Regards
HD
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!