Double summation of a matrix

2 Ansichten (letzte 30 Tage)
Psk
Psk am 22 Okt. 2020
Beantwortet: Matt J am 22 Okt. 2020
How to implement the summation? I am not able to do this.

Antworten (2)

Matt J
Matt J am 22 Okt. 2020
In recent Matlab, you can do
sum(matrix,'all')
or more generally you can do
sum(matrix(:))
  3 Kommentare
Rik
Rik am 22 Okt. 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
Matt J am 22 Okt. 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')
ans = 14.8419

Melden Sie sich an, um zu kommentieren.


Matt J
Matt J am 22 Okt. 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')

Community Treasure Hunt

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

Start Hunting!

Translated by