Griddata - extrapolation beyond the Delaunay triangulation

31 views (last 30 days)
Hi all!
I have an array (for example):
A = [1114.74,419.09,139.578;
1102.49,442.43,139.188;
1081.19,433.00,138.894;
1094.47,414.38,139.072;
1070.44,408.88,138.810;
1068.03,369.45,138.715;
1080.25,392.28,138.941;
1085.77,374.79,139.178];
And wrote a code
[griNodN,griNodE] = meshgrid(min(A(:,1)):0.1:max(A(:,1)),min(A(:,2)):0.1:max(A(:,2)));
valGridDef = griddata(A(:,2),A(:,1),A(:,3)',griNodE,griNodN,'linear');
isolin=(min(A(:,3)):0.05:max(A(:,3)));
clim([min(isolin) max(isolin)]);
contourf(griNodE,griNodN,valGridDef,isolin);
colorbar
plot(A(:,2),A(:,1),'rs','MarkerSize',10,'LineWidth',3)
the result looks as expected
In documentation is noted "For all interpolation methods other than 'v4', the output vq contains NaN values for query points outside the convex hull of the sample data. The 'v4' method performs the same calculation for all points regardless of location."
But v4 gives irrelevant result.
Is there another way to at least approximately extrapolate the surface beyond the Delaunay triangulation?

Accepted Answer

Mathieu NOE
Mathieu NOE on 19 Dec 2023
hello
to have access to extrapolation , use scatteredInterpolant instead of griddata
A = [1114.74,419.09,139.578;
1102.49,442.43,139.188;
1081.19,433.00,138.894;
1094.47,414.38,139.072;
1070.44,408.88,138.810;
1068.03,369.45,138.715;
1080.25,392.28,138.941;
1085.77,374.79,139.178];
[griNodN,griNodE] = meshgrid(min(A(:,1)):0.1:max(A(:,1)),min(A(:,2)):0.1:max(A(:,2)));
F1 = scatteredInterpolant(A(:,2),A(:,1),A(:,3),'linear','linear');
valGridDef = F1(griNodE,griNodN);
isolin=(min(A(:,3)):0.05:max(A(:,3)));
contourf(griNodE,griNodN,valGridDef,isolin)
hold on
colorbar
plot3(A(:,2),A(:,1),A(:,3),'rs','MarkerSize',10,'LineWidth',3)

More Answers (0)

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!