05、GLS库实现插值算法与matlab对比

1----------------------------------------------------------matlab-------------------------------------------------------

% 创建5x5网格数据
[X,Y] = meshgrid(0:4, 0:4);
x = X(:);
y = Y(:);
v = x.^2 + y.^2;

% 测试点
testX = [1.5; 2.0; 3.5];
testY = [1.5; 3.0; 2.5];
methods = {'linear', 'nearest', 'cubic'};

% 执行插值并显示结果
for m = 1:length(methods)
    method = methods{m};
    fprintf('\n插值方法: %s\n', method);
    fprintf('x\t\ty\t\t插值结果\n');
    fprintf('------------------------------\n');
    
    for i = 1:length(testX)
        result = griddata(x, y, v, testX(i), testY(i), method);
     

你可能感兴趣的:(matlab,开发语言)