plotting two lines intersecting at a certain point
이전 댓글 표시
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
Rik
2021년 10월 15일
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
2021년 10월 15일
채택된 답변
추가 답변 (1개)
This is equivalent to a first order free-knot spline fit. This FEX submission might be useful,
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
