Linear approximation of data set's points.

58 visualizaciones (últimos 30 días)
alessio morabito
alessio morabito el 8 de Abr. de 2021
Comentada: alessio morabito el 11 de Abr. de 2021
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 comentarios
John D'Errico
John D'Errico el 10 de Abr. de 2021
Editada: John D'Errico el 10 de Abr. de 2021
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.
alessio morabito
alessio morabito el 11 de Abr. de 2021
Ok John, but I have already written a working algorithm to approximate tangent circles, when the lines are already defined and intersect correctly. for this I was looking for a tool that could define a piecewise linear approximation of the points that belong to the lines, because I already know how to approximate the points that belong to the circle. Maybe, correct me if i'm wrong, there might be a way to use your tool to do this (approximate with a continuous linear function (with N pieces), the N survey point groups that belongs to a straight). or, maybe, i have to work with lsqlin individually for each straight, defining the condition of intersection with the next straight line in a point that is included between them.
hoping to have better explained the problem, best regards

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 8 de Abr. de 2021
Editada: John D'Errico el 8 de Abr. de 2021
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.
  1 comentario
alessio morabito
alessio morabito el 9 de Abr. de 2021
thank you so much John, it's very interesting and useful.
I'll try to explain much better my problem. i'm studying the vertical profile of a railway. in a nutshell it's composed by a succession of straights and circles (tangents to the straights between which they are included). my data set is composed by survey points, measured along the railway with an uncertainty; my goal is to approximate this data set with a succession of straights and tangent circles (with the center on the bisector of the two straights in which it's included), such that certain constraints are respected (the most important concerns deviations, so i have to set lower and upper bounds).
I'm developing an algorithm that recognize (or try to) if the survey points belong to a straight or a circle (simply, computing of the change rate of gradient). after having cataloged all the points in the single lines and circles (i have the point group that belongs to the first straight, the point group that belongs to the second straights and the point group that belongs to the first circle, tangent to the first to straights.... and so on...). So, i need to approximate all the point group that belongs to tangents with a continuous piecewise linear function, respecting lower and upper bounds constrains.
I'm not sure how could i use your tool to help me. Maybe there's a way, and i'm sure we can create a nice discussion on it.
Best Regards

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics and Optimization en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by