Fit decay curve with sum of lines ?

1 view (last 30 days)
Stefan
Stefan on 17 Oct 2014
Commented: Stefan on 21 Oct 2014
Hello everyone,
I am trying to fit a descending curve with sum of 2 lines, tried with
fittype( 'a+b*x+c+d*x', 'independent', 'x', 'dependent', 'y' );
but it fails (i.e. does not give 2 lines with 2 different slopes but similar ones, like fitting with one line). What I am trying to achieve is like having a hexagon imposed on a circle, but not necesarily, because when the lines add up, the sum is the one who follows the circles, not the individual lines. My curve looks something like this:
range=pi:pi/200:pi+pi/2;
cx=sin(range);
cy=cos(range);
figure(); plot(cx,cy);
For now I am only interested in fitting it with sum of 2 lines.

Accepted Answer

Matt J
Matt J on 17 Oct 2014
Edited: Matt J on 17 Oct 2014
A "sum of two lines" does not sound like an accurate description of what you're looking for. It sounds like the curve you're really looking for is "piece-wise linear" (the sum of 2 lines is, anyway, just another line and wouldn't be more useful than just 1 line). If so, you can probably do the fit with this FEX distribution,
A two-piece, piecewise linear curve is the same as a first-order B-spline with 1 knot.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!