Inverse/opposite of diff function?
조회 수: 13 (최근 30일)
이전 댓글 표시
I have a 480x640 matrix and would like to perform the diff function on the elements but instead of subtracting the previous element I would like to add it.
I have tried using x(2:end) + x(1:end-1) Which return the right values but instead of returning a 479x640 matrix it returns a 1x307199 matrix. How can I change the function to give the 479x640 matrix.
Thanks in advance
댓글 수: 0
채택된 답변
추가 답변 (1개)
Kristopher Anderson
2017년 11월 24일
편집: Kristopher Anderson
2017년 11월 24일
Example:
>> A = randi([1,5],1,5)
A =
1 3 5 2 1
>> B = diff(A)
B =
2 2 -3 -1
>> C = cumsum([A(1) B])
C =
1 3 5 2 1
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!