Modified Akima piecewise cubic Hermite interpolation contour plot

Hi, I have X, Y, Z data points from some field measurements in a 7x34 grid for each array, and would like to figure out how I can apply the Modified Akima piecewise cubic Hermite interpolation (makima) in order to interporlate between the data points to give a good fit for the curves and generate the new interpolated contour plot. Any guidance on how to go about it?

 Accepted Answer

hello
try this
I took the liberty to first smooth the data before doing the interpolation - you can adjust the amount of smoothing by changing the value of s_factor
smoothn can be downloaded from FEX :
The code let you see the diffeence with spline or makima interpolation methods
with your data, especially once smoothed, the difference is barely noticeable
code :
% surface contour plot with makime interpolation
load('X_data.mat');
load('Y_data.mat');
load('Z_data.mat');
%% make variables names shorter for code clarity
X = XX_Longitudinal_Positions_True;
Y = YY_Vertical_Positions_True;
Z = ZZ_Flat_Web_CLAW_Out_of_Plane_Positions;
clear XX_Longitudinal_Positions_True YY_Vertical_Positions_True ZZ_Flat_Web_CLAW_Out_of_Plane_Positions
%% smooth first
s_factor = 1; % smoothing parameter
Zs = smoothn(Z,s_factor); % FEX : https://fr.mathworks.com/matlabcentral/fileexchange/25634-smoothn/
figure(1),
subplot(121), surf(X,Y,Z), zlim([15 17]), axis square
title('raw')
subplot(122), surf(X,Y,Zs), zlim([15 17]), axis square
title('smoothn')
%% interp2 with Modified Akima piecewise cubic Hermite interpolation
[Xq2,Yq2] = meshgrid(min(X,[],'all'):2:max(X,[],'all'),min(Y,[],'all'):2:max(Y,[],'all'));
Zqs2 = interp2(X,Y,Zs,Xq2,Yq2,'spline');
figure(2),surf(Xq2,Yq2,Zqs2)
axis tight
title('2-D ''spline''')
snapnow
Zqm2 = interp2(X,Y,Zs,Xq2,Yq2,'makima');
figure(3),surf(Xq2,Yq2,Zqm2)
axis tight
title('2-D ''makima''')
figure(4),
[c,h] = contour(Xq2,Yq2,Zqm2);
clabel(c,h)
axis tight
title('2-D ''makima''')

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!