Fit a spline function to a set of data points
50 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Deepa Maheshvare
il 3 Lug 2022
Commentato: Deepa Maheshvare
il 4 Lug 2022
Hi All,
I have a set of coordinate points
x= [0,4,6,10,15,20]
y = [18,17.5,13,12,8,10]
I want to fit a spline function.
Could someone please suggest the the curve fit function that can be used?
7 Commenti
Risposta accettata
Sam Chak
il 3 Lug 2022
Thought you want the 'spline'? Is there a reason to use the 'linear' method?
x = [0, 4, 6, 10, 15, 20];
y = [18, 17.5, 13, 12, 8, 10];
xq = 0:0.01:20;
subplot(2,1,1)
yq1 = interp1(x, y, xq, 'linear');
plot(x, y, 'o', xq, yq1, '--');
ylim([5 22]), grid on, title('Linear Interpolation');
subplot(2,1,2)
yq2 = interp1(x, y, xq, 'spline');
plot(x, y, 'o', xq, yq2, '--');
ylim([5 22]), grid on, title('Spline Interpolation');
3 Commenti
Torsten
il 3 Lug 2022
Seems that order = 2 means that two coefficients are needed to describe the (linear) spline function on each subinterval and is set to 1 + degree of the interpolating polynomial. A bit confusing in my opinion.
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Splines in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!