Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fitting

Subject: fitting

From: pietro

Date: 19 Jan, 2010 14:53:02

Message: 1 of 6

I have tried to fit my data with a spline, but the result isn't good beacause introduce a small oscillation as you can see in the follow link

http://img21.imageshack.us/img21/8509/figurev.jpg

How can i improve fitting?

Subject: fitting

From: Matt J

Date: 19 Jan, 2010 15:12:05

Message: 2 of 6

"pietro " <bracardi82@email.it> wrote in message <hj4h0e$hv5$1@fred.mathworks.com>...
> I have tried to fit my data with a spline, but the result isn't good beacause introduce a small oscillation as you can see in the follow link
>
> http://img21.imageshack.us/img21/8509/figurev.jpg
>
> How can i improve fitting?

How do you know your actual function doesn't oscillate like this in between the samples? If you know this for a fact, then you can put synthetic data points in between the data points you already have, which behave as you think the function should. You can then repeat the spline fit on the finer set of data points.
 

Subject: fitting

From: ImageAnalyst

Date: 19 Jan, 2010 15:25:31

Message: 3 of 6

pietro
You might give John D'Errico's masterpiece a try:
http://www.mathworks.com/matlabcentral/fileexchange/24443

Subject: fitting

From: Rob Campbell

Date: 19 Jan, 2010 16:23:04

Message: 4 of 6

It looks like the main problem is that you only have 8 points. If that's all there is then maybe you shouldn't fit anything to it at all. What are you trying to achieve with the fit?

Subject: fitting

From: Matt J

Date: 19 Jan, 2010 17:28:05

Message: 5 of 6

"pietro " <bracardi82@email.it> wrote in message <hj4h0e$hv5$1@fred.mathworks.com>...
> I have tried to fit my data with a spline, but the result isn't good beacause introduce a small oscillation as you can see in the follow link
>
> http://img21.imageshack.us/img21/8509/figurev.jpg
>
> How can i improve fitting?

Clearly you're using cardinal or B-splines. Do you really need a closed-form expression for the fit and do you need really need the fit to be N times differentiable? If not, why not just use interp1 with the 'pchip' option. When I do this with data very similar to yours, I get a pretty non-oscillatory fit

%data
y=[.7, .95, .91, .3, .78, .83, .86, .82];
x=.2:.2:1.6;

%engine
xx=linspace(x(1),x(end), 10000);
plot(x,y,xx,interp1(x,y,xx,'pchip'))

Subject: fitting

From: pietro

Date: 8 Feb, 2010 16:43:04

Message: 6 of 6

"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hj4q34$ejb$1@fred.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <hj4h0e$hv5$1@fred.mathworks.com>...
> > I have tried to fit my data with a spline, but the result isn't good beacause introduce a small oscillation as you can see in the follow link
> >
> > http://img21.imageshack.us/img21/8509/figurev.jpg
> >
> > How can i improve fitting?
>
> Clearly you're using cardinal or B-splines. Do you really need a closed-form expression for the fit and do you need really need the fit to be N times differentiable? If not, why not just use interp1 with the 'pchip' option. When I do this with data very similar to yours, I get a pretty non-oscillatory fit
>
> %data
> y=[.7, .95, .91, .3, .78, .83, .86, .82];
> x=.2:.2:1.6;
>
> %engine
> xx=linspace(x(1),x(end), 10000);
> plot(x,y,xx,interp1(x,y,xx,'pchip'))

Thank you it works perfectly

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us