curve fitting: how to get the fitting curve?

조회 수: 1 (최근 30일)
Yuji Zhang
Yuji Zhang 2013년 12월 6일
댓글: Yuji Zhang 2013년 12월 9일
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!

답변 (1개)

John D'Errico
John D'Errico 2013년 12월 6일
편집: John D'Errico 2013년 12월 6일
Use pchip to create a shape preserving spline. ppval can evaluate it.
  댓글 수: 2
Yuji Zhang
Yuji Zhang 2013년 12월 9일
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 2013년 12월 9일
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~

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by