Quadratic Spline Interpolation Code

21 ビュー (過去 30 日間)
Kimberlin Sookchand
Kimberlin Sookchand 2020 年 4 月 28 日
編集済み: John D'Errico 2020 年 12 月 14 日
What is the MATLAB code for quadratic splines? As linear uses interp1 linear and cubic splines uses interp1 spline. What is the corresponding interp1 coding for quadratic splines?
  1 件のコメント
darova
darova 2020 年 4 月 28 日
Matlab has no quadratic spline

サインインしてコメントする。

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 4 月 28 日
編集済み: Ameer Hamza 2020 年 4 月 28 日
You can write your own quadratic spline function
function yq = quadSpline(x, y, xq)
X = [x(:).^2 x(:) ones(size(x(:)))];
coff = X\y(:);
yq = [xq(:).^2 xq(:) ones(size(xq(:)))]*coff;
end
Example
x = 1:10;
y = x.^2 + 5 + rand(size(x))*10;
xq = linspace(0,10);
yq = quadSpline(x, y, xq);
plot(x, y, 'r+', 'MarkerSize', 10, 'LineWidth', 2);
hold on
plot(xq, yq, 'b-');
  4 件のコメント
Enes Senel
Enes Senel 2020 年 12 月 14 日
splines should pass from data points. This seems like polynomial regression
John D'Errico
John D'Errico 2020 年 12 月 14 日
編集済み: John D'Errico 2020 年 12 月 14 日
The comments are correct. This is NOT a quadratic spline tool. All that is given in this answer is a quadratic polynomial regression. That is not a spline. The comment about a spline passing through the data points is not always correct though. An INTERPOLATING spline passes through the data points. However, regression or smoothing splines need not do so. But as said, this still is not a spline, in the sense that a spline is a piecewise function.

サインインしてコメントする。


Bruno Luong
Bruno Luong 2020 年 12 月 14 日
My toolbox provide any order (1D) spline, including quadratic

カテゴリ

Help Center および File ExchangeSpline Postprocessing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by