- If X is a vector of length m, then Y = diff(X) returns a vector of length m-1. The elements of Y are the differences between adjacent elements of X.Y = [X(2)-X(1) X(3)-X(2) ... X(m)-X(m-1)]
create a new column of data showing (n+1)-n of old column
2 views (last 30 days)
Show older comments
Joseph Tirado
on 16 Jan 2022
Commented: Joseph Tirado
on 17 Jan 2022
I need to find the amount each data point increases by for each point in a clumn of data. I want to create a new column that calcuates the next point subtracted by the point right before it. if the colmn was labeled "x" it would function something like this: x(n+1)-x(n). Can anyone help?
0 Comments
Accepted Answer
Cris LaPierre
on 16 Jan 2022
More Answers (1)
Image Analyst
on 16 Jan 2022
Edited: Image Analyst
on 16 Jan 2022
Do you mean like using the diff() function?
m = randi(9, 5, 7)
dHoriz = diff(m, 1, 2)
dVert = diff(m, 1, 1)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!