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

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.

답변 (2개)

datapoint - your vector
out = -diff(datapoint);

댓글 수: 3

@Bob: Please do not only claim, that it does not help you. It would be more useful if you explain, which problems you have.
While I prefer Andrei's suggestion (why does it not help you?), what about this:
result = datapoint(1:end - 1) - datapoint(2:end)

이 질문은 마감되었습니다.

제품

질문:

2014년 5월 17일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by