For an×m Matrix:
Set the sum
to 0, column
to 1 and top
to n (assuming (n,1)
is the bottom-left corner of the matrix)
Add to the sum
all elements in current column which row number is more or equal to the top
.
Add 1 to column
. If column
is greater than m
we are done.
Subtract 1 from top
. If top
is 0
, set top
to 1
.
Go to 1.
对于矩阵M
Mysum = sum(sum(tril(rot90(M,-1))))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.