# How to get original values from cumulative sum values?

25 visualizaciones (últimos 30 días)
Niraj Bal Tamang el 19 de Jun. de 2022
Respondida: Stephen23 el 19 de Jun. de 2022
I have a list of cumulative sum values. I want to obtain another list with the values that generated the cumulative sum vaues. Something like a reverse cumulative sum process. I tried (X2-X1) formula for each consecutive value but couldn't get the exact values. Can someone please help me to reverse the cumulative sum values to original values.
Thank you
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Stephen23 el 19 de Jun. de 2022
X = rand(1,9)
X = 1×9
0.8615 0.8710 0.7907 0.5073 0.3673 0.4523 0.4018 0.2258 0.1596
Y = cumsum(X)
Y = 1×9
0.8615 1.7326 2.5233 3.0306 3.3979 3.8502 4.2520 4.4778 4.6374
Z = [Y(1),diff(Y)]
Z = 1×9
0.8615 0.8710 0.7907 0.5073 0.3673 0.4523 0.4018 0.2258 0.1596
max(X-Z) % alomsot zero
ans = 4.4409e-16
Because of the accumulated floating point error getting exactly the same values is not expected.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre MATLAB Mobile en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by