How to find where the differences between elements is constant?

So let's say these are my values:
x y
0 29
0 30
0 30
16760 30
16760 31
16760 31
16760 31
16760 31
16760 31
16760 32
16760 32
16760 32
16760 32
16760 33
16760 32
16760 33
16760 33
16760 33
16760 33
16760 33
16760 34
16760 34
16760 33
18330 34
18330 33
18330 35
19130 35
19130 35
what i need to know is for the periods that x is constant, the values of y (in my problem y is actually speed so i need the values to integrate and find distance afterwards)
so i would like to have as a result something like for x1=16760,y=30 31 31 31 31 31 32 32 32 32 33 32 33 33 33 33 33 34 34 33
x2=18330, y=34 33 35
x3=19130, y=35 35
etc..
Is that possible? any suggestion is welcome! thank you!

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2014년 5월 22일
xy = [0 29
0 30
0 30
16760 30
16760 31
16760 31
16760 31
16760 31
16760 31
16760 32
16760 32
16760 32
16760 32
16760 33
16760 32
16760 33
16760 33
16760 33
16760 33
16760 33
16760 34
16760 34
16760 33
18330 34
18330 33
18330 35
19130 35
19130 35];
[a,~,c] = unique(xy(:,1));
out = [num2cell(a), accumarray(c,xy(:,2),[],@(x){x})];

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

질문:

2014년 5월 22일

댓글:

2014년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by