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

8 visualizzazioni (ultimi 30 giorni)
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 Commenti
dpb
dpb il 4 Ott 2016
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 il 5 Ott 2016
Modificato: Abdulaziz Abutunis il 5 Ott 2016
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];

Accedi per commentare.

Risposte (2)

John D'Errico
John D'Errico il 4 Ott 2016
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 Commento
Abdulaziz Abutunis
Abdulaziz Abutunis il 5 Ott 2016
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];

Accedi per commentare.


dpb
dpb il 5 Ott 2016
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
>>

Categorie

Scopri di più su Historical Contests in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by