Going back from cumsum for a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Suppose I cumsum a matrix, say A=rand(3,3); B=cumsum(A).
Knowing B, how to I get back to A, in a reasonably efficient way, for a rather large B?
Thanks!
채택된 답변
David Hill
2022년 10월 21일
A=round(rand(100,100),4);
B=cumsum(A);
a=round([B(1,:);diff(B)],4);
isequal(A,a)
댓글 수: 1
Walter Roberson
2022년 10월 21일
Right.
Key points here are the use of diff(), the duplication of the first entry, and the rounding or other way of comparing with tolerance for the cross-check (since you would need to deal with round-off errors.)
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!