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