How to do piecewise linear approximation from x and y points?
Mostra commenti meno recenti
I have x and y points as follows:
x = [20 60 240 480 1440 2880];
y = [0.0278 0.1626 1.8126 4.006 18.2491 44.4084]
I am trying to do the piecewise linear approximation to get the equation of the line. How can I proceed? I have used polyfit function and got the slope and interception for the line. However, I am not sure if it is correct or not? For example, if value of x is < 60, I am getting a negative value of y from the defined fuction from polyfit.
Risposta accettata
Più risposte (2)
Walter Roberson
il 23 Nov 2022
Modificato: Walter Roberson
il 23 Nov 2022
0 voti
A piecewise linear approximation could have a piecewise break at or between any pair of points, and is therefore not unique. You would have to constrain the approximation to have a hope.
For example you could require a break exactly half-way between two points if the previous segment was length 2 or more and the projected estimate at the additional point would be more than 10% different than the point.
(Notice that this rule has potential problem, such as what to do if that would leave an isolated point; notice too that because it depends upon value of the point, the effect of the difference depends on how close to the axes you are. A difference of 10 might be immaterial if the y coordinate were a million -- but on the other hand if you translated the coordinates down by a million and had the same relative values near the axes, is a difference of 10 suddenly relevant?)
Image Analyst
il 23 Nov 2022
0 voti
I really see no point in fitting two lines to data where there is only 6 points. With so few points there is essentially no confidence that the lines will be much like what they would be if you had hundreds of points. So why bother? What are you going to do with this information?
Nonetheless, you can try my piecewise fitting demo, attached.
Categorie
Scopri di più su Resampling Techniques 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!


