Double summation of a matrix
4 views (last 30 days)
Show older comments
How to implement the summation? I am not able to do this.
0 Comments
Answers (2)
Matt J
on 22 Oct 2020
In recent Matlab, you can do
sum(matrix,'all')
or more generally you can do
sum(matrix(:))
3 Comments
Rik
on 22 Oct 2020
Just an addition: Since R2018b you can use the S = sum(A,vecdim) syntax. So if you happen to have a 3D array and want to sum only rows and columns you can use this:
sum(matrix,[1 2])
Matt J
on 22 Oct 2020
Then how will i specify the limits for summation?
You can extract the appropriate sub-matrix by indexing it, e.g.,
A=rand(10);
sum(A(1:5,2:7),'all')
Matt J
on 22 Oct 2020
The expression in your .jpg file, if it needs to be evaulated for all p,q would be
SML=conv2(ML,ones(N+1),'same')
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!