Linear approximation of data set's points.
58 次查看(过去 30 天)
显示 更早的评论
i have a data set (x,y) that i have to approximate with a piecewise linear function, such that lower and upper bounds are satisfied. the image show what's the result I would like to achieve (in red the data set's points; in grey, the linear continuous approximation i would like to describe)image of result to achieve.
Using Matlab, i've divided all points in groups (one for every linear segment) and approximated every linear segment, with needed constraints, in the sense of least squares. But i need to have a continuous function and I am stuck in solving the problem. There's someone that have an idea of what i can do to solve the problem?
thanks in advance to everyone
2 个评论
John D'Errico
2021-4-10
编辑:John D'Errico
2021-4-10
You could have saved us some time if you actually said this was what you want to do, instead of saying you wanted a continuous piecewise linear approximation. No. You cannot use that tool to create a curve that is partly circular arcs, and partly linear segments.
It looks like you have asked this question again anyway. Please don't ask it a third time.
回答(1 个)
John D'Errico
2021-4-8
编辑:John D'Errico
2021-4-8
Don't do it that way!!!!!!! You cannot achieve a continuous piecewise linear function that way. Instead, use a tool designed to solve that problem. For example:
x = rand(1,100);
y = sin(pi*x);
slm = slmengine(x,y,'knots',0:0.2:1,'degree','linear','plot','on');
So piecewise linear segments, fit using least squares. Breaks at the points 0:.2:1.
You can find my SLM toolbox for free download from the file exchange, here:
You can use the resulting structure, evaluating the function, or you could even extract the linear segments.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!