Code covered by the BSD License

### Highlights from BrokenStickRegression

5.0

5.0 | 4 ratings Rate this file 37 Downloads (last 30 days) File Size: 3.66 KB File ID: #29387

# BrokenStickRegression

13 Nov 2010 (Updated )

A line consisting of connected straight sections is fitted to a cloud of data points.

File Information
Description

A line of connected straight sections is fitted to a 2D-cloud of data points. The sections are described by the coordinates of their endpoints. No toolbox required.

Acknowledgements

This file inspired Aquiles.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements none
Tags for This File   Please login to tag files.
 Please login to add a comment or rating.
Comments and Ratings (9)
14 Mar 2014
01 Jul 2013

Hello
I really appreciated this code as it does exactly what I've been looking for... I intend to cite this code in a future publication. How should I do it? Just giving your name and the code's along with the Mathworks website? Ph.D. student, here, it's the first time I want to use some other people's work... Thanks in advance!

08 Feb 2013

@Brad:
thanks for the rating! I have no version that uses fmincon because I do not own fmincon. There may be such code somewhere. The cost function is the sum of the squared differences between the data points and the regression line sections. I presume that the constraints would be the same as used in BrokenStickRegression. These require that all corner points stay within the data cloud and that no corner point may jump over an adjacent point, i.e. the sequence of the corner points must be preserved. -- Peter

07 Feb 2013

Hi Peter,

Great function. Is there a version that implements the fmincon as commented in the code. If not...what would the cost function and constraints be?

Thanks, in advance!

03 Sep 2012

@Seth: the code returns the coordinates of the breakpoints.

14 Aug 2012

Dear Mr. Nave,
I am using your algorithm Broken Stick Regression on a data analysis project at Harvard University. I would really appreciate if you took the time to answer a question about the algorithm. After I write something like:
ao1 = BrokenStickRegression (i1,v1,3);
p5 = plot(ao1(:,1), ao1(:,2));
set(p5,'Color','red','LineWidth',2);

What can I do to obtain the coordinates of each break point?

thank you very much. Please send your response to sethneel@college.harvard.edu if you have time.
best,
Seth Neel

15 Sep 2011

@ Atui Ingle:
most probably, but I do not know of any; I "invented" the algorithm. The "penalty" method is very old and well known. -- Peter

14 Sep 2011

Is there a literature reference for the method used in the code?

01 Sep 2011

Really well written code, exactly what I was looking for.

I want to specify only one breakpoint in between the end points -- something this code doesn't allow. But I guess it's an easy modification that I can make if needed.

Updates
15 Nov 2010

Code shortened by ca. 20%.

02 Dec 2010

Two bugs detected by Carlos Romero fixed (thanks!). Initial trial breakpoints can now be specified. More error checks provided.

05 Dec 2010

Typographical errors corrected

04 Sep 2011

Improved checks on input; allows a single abscissa point as starting breakpoint.

04 Sep 2011

Further simplifications of the algorithm.

07 Nov 2013

Admits weighting of the input data.

08 Nov 2013

updated Products Required

Contact us