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
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...
回答(2 个)
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.
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
>>
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Smoothing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!