plotting two lines intersecting at a certain point
Mostra commenti meno recenti
Hello friends, I have got some data and i want to draw two lines of best fit, one from the left and the other from the right that intersect at certain point. I need to read that point for further analysis. But am not sure how to go about that. Here is my data and some ploting
>>Temp=[25 26 26 26.5 27 27 27.5 28 28 28.5 29 29 29 29 29 29 29 29 29 29 29 29 29 28.5 28.5 28]';
>> vol=[0:25]';
>> scatter(vol,Temp);
>>a=gca;ax=axis;ax(3:4)=[25 32];a.YLim=ax(3:4)

2 Commenti
Rik
il 15 Ott 2021
This data has two pivots: one at 10 and another at 22. Which one do you want?
My first try would probably be to loop over all possible pivots and see which pivot will result in the best fit for the two lines. I suspect polyfit will already be enough, your data looks clean enough.
Samuel Katongole
il 15 Ott 2021
Risposta accettata
Più risposte (1)
This is equivalent to a first order free-knot spline fit. This FEX submission might be useful,
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
