Help with implementing parametric spline interpolation
Mostrar comentarios más antiguos
Hi.
In the attachments I have a matlab-file where I am seeking a quadratic interpolant of type l_i(t) = c_i * t^2 + b_i * t + a_i.
Can you help me finding a solution for a quadratic interpolant of type l_i(t) = a_i*t^3+b_i*t^2+c_i*t+d_i ?
This is what I've done so far:
% 2aa., per coordinate and per interpolant: 4 equations:
% (1) l_i(0) = d_i = p_i
% (2) l_i(1) = a_i + b_i + c_i + d_i = p_{i+1}
% (3) l_i'(1) = l{i+1)'(0)
% --> 3 * a_i + 2 * b_i + c_i - c_{i+1} = 0
% (4) l_i''(1) = 6 * a_i + 2 * b_i - b_{i+1} = 0
e = 4 %% number of equations per interpolant and per coordinate
A = zeros(e*n); %% empty matrix-setup
bX = zeros(e*n, 1); %% empty setup of the right-hand side (for x)
bY = zeros(e*n, 1); %% empty setup of the right-hand side (for y)
for i = 0:n-1
% first equation per interpolant and per coordinate
A(1+e*i, 1+e*i) = 1;
bX(1+e*i) = p(1+i, 1);
bY(1+e*i) = p(1+i, 2);
% second equation per interpolant and per coordinate
A(2+e*i, 1+e*i) = 1;
A(2+e*i, 2+e*i) = 1;
A(2+e*i, 3+e*i) = 1;
%A(2+e*i, 4+e*i) = 1;
bX(2+e*i) = p(2+i, 1);
bY(2+e*i) = p(2+i, 2);
% third equation per interpolant and per coordinate
if i < n-1
A(3+e*i, 2+e*i) = 1;
A(3+e*i, 3+e*i) = 2;
A(3+e*i, 5+e*i) = -1;
%A(3+e*i, 7+e*i) = -2;
else
A(e*n, 2) = 1;
bX(e*n) = 1;
bY(e*n) = 1;
end
%fourth equation per interpolant and per coordinate
if i < n-2
A(4+e*i, 3+e*i) = 1;
A(4+e*i, 4+e*i) = 2;
A(4+e*i, 7+e*i) = -1;
%A(4+e*i, 7+e*i) = -2;
else
A(e*n, 2) = 1;
bX(e*n) = 1;
bY(e*n) = 1;
end
end
Best regards,
Eirik
Respuestas (0)
Categorías
Más información sobre Interpolation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!