What is the mathematical principle of two-dimensional cubic Spline interpolation ?

8 views (last 30 days)
What is the mathematical principle of two-dimensional cubic Spline interpolation(the function: interp2(method=spline))in Matlab?
Can you provide a link or paper?
I know that in the case of one-dimensional data, Cubic function is required, but I don't understand two-dimensional data.

Accepted Answer

Bruno Luong
Bruno Luong on 27 Jun 2023
The 2D spline is tensorial of 1D splines, meaning it makes 1D is x, then 1D in y. If you do the other way around it give the same result.
  4 Comments
Bruno Luong
Bruno Luong on 28 Jun 2023
Edited: Bruno Luong on 28 Jun 2023
Code to illustrate
% Generate grid data (4 x 4)
p = 4;
x=1:p;
y=1:p;
[X,Y] = ndgrid(x,y);
Z = peaks(p);
% Generate fine query (grid) points
xq = 1:0.1:p;
yq = 1:0.1:p;
[XQ,YQ] = ndgrid(xq,yq);
% MATLAB spline 2D interpolation
ZQ = interp2(Y,X,Z,YQ,XQ,'spline');
[m,n] = size(Z);
G = zeros(size(XQ));
f = zeros(1,n);
for k=1:numel(XQ) % loop on the query points
xq = XQ(k);
yq = YQ(k);
% tensorial interpolation in x
for j=1:n
f(j) = interp1(x, Z(:,j), xq, 'spline');
end
% then in y
g = interp1(y, f, yq, 'spline');
% store the result
G(k) = g;
end
norm(ZQ(:)-G(:),'inf')
ans = 0
% Graphical Check
figure
subplot(2,1,1)
surf(ZQ)
title('interp2')
subplot(2,1,2)
surf(G)
title('tensorial interp1 (x/y)')

Sign in to comment.

More Answers (0)

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!