フィルターのクリア

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 Center および File ExchangeGet 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