From: Doug Weathers on
I am working with a tensile tester that performs an intermittent load-hold test profile. The load is steadily increased, then held for some period of time, then steadily reduced, then held, etc. The result is over 10,000 data points that form a lovely graph of load vs. time, made up out of a series of straight lines.

I want the starting and ending points for each segment, and the slopes of the lines.

The various functions I've tried, such as INTERP1 and SPLINE, want to use all of the data points. They (apparently) can't be told to find appropriate intervals on their own.

I could manually feed the intervals to the program and get the results I want, but I want this to work with any output file, without requiring manual intervention.

Any suggestions?
From: John D'Errico on
"Doug Weathers" <dougw(a)spamcop.net> wrote in message <hvtl8c$l97$1(a)fred.mathworks.com>...
> I am working with a tensile tester that performs an intermittent load-hold test profile. The load is steadily increased, then held for some period of time, then steadily reduced, then held, etc. The result is over 10,000 data points that form a lovely graph of load vs. time, made up out of a series of straight lines.
>
> I want the starting and ending points for each segment, and the slopes of the lines.
>
> The various functions I've tried, such as INTERP1 and SPLINE, want to use all of the data points. They (apparently) can't be told to find appropriate intervals on their own.
>
> I could manually feed the intervals to the program and get the results I want, but I want this to work with any output file, without requiring manual intervention.
>
> Any suggestions?

When you don't know the break points, this is what
is often called a free knot spline. The knots or breaks
must be estimated. No, an interpolating spline cannot
solve that problem, as they are INTERPOLATING
SPLINES!

There are several tools on the file exchange that do it
for you. My own SLM tools will find the breaks as well
as fit the spline for you. I do require the presence of
the optimization toolbox though.

Find SLM here:

http://www.mathworks.com/matlabcentral/fileexchange/24443

HTH,
John
From: Bruno Luong on
"Doug Weathers" <dougw(a)spamcop.net> wrote in message <hvtl8c$l97$1(a)fred.mathworks.com>...
> I am working with a tensile tester that performs an intermittent load-hold test profile. The load is steadily increased, then held for some period of time, then steadily reduced, then held, etc. The result is over 10,000 data points that form a lovely graph of load vs. time, made up out of a series of straight lines.
>
> I want the starting and ending points for each segment, and the slopes of the lines.
>
> The various functions I've tried, such as INTERP1 and SPLINE, want to use all of the data points. They (apparently) can't be told to find appropriate intervals on their own.

The simple method that could fit your need is Douglas-Peucker:

http://www.mathworks.com/matlabcentral/fileexchange/?term=line+simplification

Which select the cross points that fall exactly at data coordinates.

If you relax the constraint, then John point right to free-knot splines method. Beside his SLM tool, you can find mine that has a feature of removing automatically redundant knots.

http://www.mathworks.com/matlabcentral/fileexchange/25872-free-knot-spline-approximation

% Generate piecewice linear data with noise
edges = cumsum(1+rand(1,5));
x = linspace(0,max(edges));
y = BBspline(x, edges, 2, randn(1,length(edges)-2)); % function in the FEX
y=y+0.01*randn(size(y));

% Engine
pp = BSFK(x,y,2,[],[],struct('Animation',1))

% Bruno
From: Doug Weathers on
"John D'Errico" <woodchips(a)rochester.rr.com> wrote in message

> When you don't know the break points, this is what
> is often called a free knot spline. The knots or breaks
> must be estimated.

Great, I now have search keywords. Thanks!

> My own SLM tools will find the breaks as well
> as fit the spline for you. I do require the presence of
> the optimization toolbox though.

Very nice work.

Sadly, I've been playing with SLM and haven't been able to get it to do what I want.

The strength of SLM appears to be in fitting a curve to a particular data set. It allows you to play around with the data set - setting up prescriptions and knot points, plotting and tweaking, etc. until you have a very good fit.

However, I'm looking for a tool that can fit a curve to an arbitrary data set, without a lot of tweaking. I have a lot of data sets to analyze, and they are piecewise linear functions without a lot of noise. The problem is that I can't predict where the internal knots will be.

If you're so inclined, you can download a sampe dataset here:

<http://dl.dropbox.com/u/4238208/ilh-load.mat>

and have a look at it.

My best effort so far is this:

load ilh-load;
slm = slmengine(x,y,'interiorknots','free', 'degree','linear','plot','on');

TIA,

Doug
From: Bruno Luong on
This is what I got http://yfrog.com/5hxjqp

The only tweaking is increase the number of initial knots to 40 since there are many periods. Command used:

pp = BSFK(x,y,2,40,[],struct('Animation',1))

The last interval does not work well because there are 4 data points that drop sharply to 0 at the very end. If you remove the last 4 data points, it will work just fine.

BSFK is slow for 40 knots points, since a the Jacobian calculation is not optimally carried out. I must find time to improve that aspect some day.

Bruno