how to sum each element in matrix

1 次查看(过去 30 天)
mts
mts 2018-8-20
so I have this matrix and i want to sum of the each element of matrix like in this picture.how can i do that.
  3 个评论
Image Analyst
Image Analyst 2018-8-20
No, I can't see. What arrows? What numbers are the sum of what other two numbers? And where is the square?
mts
mts 2018-8-21
I mean red line , yellow line and black line are sum of two numbers also black rectangle is sum of three numbers and red rectangle is sum of four numbers

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2018-8-21
You say "I mean red line , yellow line and black line are sum of two numbers also black rectangle is sum of three numbers and red rectangle is sum of four numbers" so
redLineSumOf2 = A(1,1) + A(1,4)
yellowLineSumOf2 = A(1,1) + A(1,3)
blackLineSumOf2 = A(1,1) + A(1,2)
blackRectSumOf3 = sum(A(1, 1:3))
redRectSumOf4 = sum(A(1, 1:4))

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by