curve fitting: how to get the fitting curve?

1 Ansicht (letzte 30 Tage)
Yuji Zhang
Yuji Zhang am 6 Dez. 2013
Kommentiert: Yuji Zhang am 9 Dez. 2013
Hi everyone~
I did some curve fitting using curve fitting toolbox. But I don't know how to get the fitting curve. Can somebody help?
Also, in the future I want to do this using code. I'm reading the manual for spline fitting. http://www.mathworks.com/help/curvefit/construction.html
There seems to be lots of kinds of it. I want it shape-conserve, and must pass all the points. Which one should I use?
Any help is appreciated. Thank you!

Antworten (1)

John D'Errico
John D'Errico am 6 Dez. 2013
Bearbeitet: John D'Errico am 6 Dez. 2013
Use pchip to create a shape preserving spline. ppval can evaluate it.
  2 Kommentare
Yuji Zhang
Yuji Zhang am 9 Dez. 2013
Hi Thanks John~
I did testing and found "spline" is more shape-preserving. See the example.
Do you know how I can control the curve to go up or down at the side where there's no data? Any discussion's appreciated. Thank u~
Example: circles: data (4 points)
blue curve: pchip
red curve: spline
code:
x0 = [-10 -5 0 5 ];
y0 = [-50 -10 0 -10];
x = -50:0.1:50;
y1 = pchip (x0, y0, x);
y2 = spline (x0, y0, x);
plot(x0, y0, 'o');
hold on;
plot(x, y1,'b');
plot(x, y2,'r');
Yuji Zhang
Yuji Zhang am 9 Dez. 2013
Hi John~
Actually too bad. For my case, "pchip" doesn't work for the left end, and "spline" doesn't work for the right end. I just want a bell shape facing down.
See the plot:
Code:
x0 = [-10 -5 0 5 100];
y0 = [-50 -10 0 -10 -200];
x = -300:0.1:300;
y1 = pchip (x0, y0, x);
y2 = spline (x0, y0, x);
plot(x0, y0, 'o');
hold on;
plot(x, y1,'b');
plot(x, y2,'r');
ylim([-700 200]);
Let me know is there any way to fix it. Thanks a lot~

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by