Info

This question is closed. Reopen it to edit or answer.

From a large single column set of data, how can I get the differences between data points above and below each other?

1 view (last 30 days)
I have this problem whereby i need to find the difference between a single column set of data. For example, datapoint1-datapoint2...datapoint2-datapoint3...datapoint3-datapoint4 and so on for 170 data points. I want to find a way in which i can display these differences in a vector without having to tediously write every single data point subtraction.

Answers (2)

Andrei Bobrov
Andrei Bobrov on 17 May 2014
Edited: Andrei Bobrov on 17 May 2014
datapoint - your vector
out = -diff(datapoint);
  3 Comments
Jan
Jan on 17 May 2014
@Bob: Please do not only claim, that it does not help you. It would be more useful if you explain, which problems you have.

Jan
Jan on 17 May 2014
While I prefer Andrei's suggestion (why does it not help you?), what about this:
result = datapoint(1:end - 1) - datapoint(2:end)

Products

Community Treasure Hunt

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

Start Hunting!