Summing the diagonal of a matrix "the other way"?
12 次查看(过去 30 天)
显示 更早的评论
I don't know if I'm wording it correctly, but I'm trying to sum the diagonal of a matrix the other "direction" than the diag(A) function. For example, I have a matrix:
A =
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
If I use diag(A), it'd give me 1 + 6 + 11 + 16, but I'm looking for:
1
2 + 5
3 + 6 + 9
4 + 7 + 10 + 13
And put all the sums in a 1xn array, much like a Fibonacci sequence. Is there a function that can do this, or can diag(A) be altered in someway?
1 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!