How to locating the linear segment of a curve data and calculate the slope and interception?

7 次查看(过去 30 天)
Dear Matlab experts,
I have a set of non-linear data that has a linear segment close to the lift end of the curve. I wonder how to use the gradient function or any other function to locate the best range of points that represents the linear segment and thin find the slop and the interception point of this linear segment. An example of one of the sets of data is given below as x and y arrays
x=[-5,-4,-3,-2,1,0,1,2,3,4,5,6,7,8,9,10];
y=[-0.2757, -0.3914, -0.4219, -0.3808, 0.3122, 0.1272, 0.08, 0.1745, 0.2545, 0.327, 0.3932, 0.4539, 0.5091, 0.559, 0.604,0.645];
Thanks all, Aziz
  2 个评论
dpb
dpb 2016-10-4
What, specifically, in the following image do you consider the interesting area and how do you know that's it???? Looks pretty funky to me...
Abdulaziz Abutunis
Abdulaziz Abutunis 2016-10-5
编辑:Abdulaziz Abutunis 2016-10-5
It looks like that when i copied arranged and pasted the data I have missed with some of them, sorry. The actual set is as below and the linear segment always crosses y coordinate means that the linear segment should have negative and positive elements from x array and usually between -4 and 5 but sometimes this range increases or decreases.
X=[ -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10];
y=[ -0.2757 -0.3914 -0.4219 -0.3808 -0.3122 -0.1272 0.0800 0.1745 0.2545 0.3270 0.3932 0.4539 0.5091 0.5590 0.6040 0.6450];

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2016-10-4
It this data is typical of your data, its not gonna happen.
Which linear segment are you referring to? Even if we ignore the apparent jump discontinuity in the middle of the curve, I don't see any obviously linear segment. Ok, take any pair of points, and we can put a linear segment between them. Otherwise, the curve seems to have a nice, smooth roll-over, with a continuously changing slope.
Getting a computer to do what you can see with your eyes is sometimes difficult. Getting a computer to do magic will be a bit harder.
  1 个评论
Abdulaziz Abutunis
Abdulaziz Abutunis 2016-10-5
It looks like that when i copied arranged and pasted the data I have missed with some of them, sorry. The actual set is as below and the linear segment always crosses y coordinate means that the linear segment should have negative and positive elements from x array and usually between -4 and 5 but sometimes this range increases or decreases.
X=[ -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10];
y=[ -0.2757 -0.3914 -0.4219 -0.3808 -0.3122 -0.1272 0.0800 0.1745 0.2545 0.3270 0.3932 0.4539 0.5091 0.5590 0.6040 0.6450];

请先登录,再进行评论。


dpb
dpb 2016-10-5
Well, cleaning up the dataset does help at least some...it's pretty flimsy test and probably not at all robust, but you might start with just simple differences as you surmised--
results from
>> plot(x,y,'o-')
>> dy=diff(y);
>> hold all
>> plot(x(2:end),dy,'o-')
>> d2y=diff(dy);
>> plot(x(3:end),d2y,'o-')
>> legend('y','dy','d^{2}y','location','best')
>> [~,i1]=(max(diff(dy))),[~,i2]=(min(diff(dy)))
i1 =
4
i2 =
6
>>

类别

Help CenterFile Exchange 中查找有关 Smoothing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by