Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
A= [ 1 2 4 2 3 1 3 1 2 ]
所以上面矩阵的答案应该是:
B = [ 1 3 7 9 12 13 16 17 19 ]
谢谢
摆弄cumsum并reshape可以让你到达那里:
cumsum
reshape
B = reshape(cumsum(reshape(A', 1, [])), size(A))' %# Equivalent to: B = A'; B = reshape(cumsum(B(:)), size(A))'
这产生:
B = 1 3 7 9 12 13 16 17 19