Stuart’s MATLAB Videos

Watch and Learn

Piecewise linear curve fitting

This week, I am getting back to my blogging roots and I want to highlight (and thank) John D’errico for a great file Exchange submission. That file is Shape Language Modeling.

Recently I had some very noisy data that I wanted to fit a curve to. The problem is there were different regions that were somewhat linear, but the overall data was far from linear. A spline or a polynomial did not capture the behavior in a global sense. What I wanted was the ability to fit a line to each region. SLM does that right out of the box.

I think it is very instructive to look at how this code was packaged up. There is a clearly labeled tutorial that was easy to scan looking for an example like what I wanted to do. All of the files have lots of comments. sometimes more comments that code I think. The files are named coherently so they make a nice package. These are all great things to make a package that other people can use.

|

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.