0001 function demoRBFInterpolantWithTension(dataId, rbfWithTensionType, tensions)
0002
0003
0004
0005 if nargin < 1 || isempty(dataId)
0006 dataId = 'seamount';
0007 end
0008
0009 if nargin < 2
0010
0011 rbfWithTensionType = 'greenwithtension';
0012 end
0013
0014
0015
0016
0017
0018 [x, y, z, xi, yi, zt, demoOptions] = getSampleDataset(dataId);
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 if nargin < 3
0033
0034 tensions = 0.1:0.1:0.9;
0035 end
0036 spNumCols = 4;
0037 spNumRows = ceil((numel(tensions)+2) / spNumCols);
0038
0039
0040 figure;
0041 xLabel = demoOptions.Plot.XLabel;
0042 yLabel = demoOptions.Plot.YLabel;
0043 zLabel = demoOptions.Plot.ZLabel;
0044 axisEqual = demoOptions.Plot.AxisEqual;
0045 if ~isempty(zt)
0046 plotResult([], [], [], xi, yi, zt, spNumRows, spNumCols, 1, 'Original Function', xLabel, yLabel, zLabel, axisEqual);
0047 else
0048
0049 end
0050
0051
0052 plotResult(x, y, z, [], [], [], spNumRows, spNumCols, 2, 'Input Samples', xLabel, yLabel, zLabel, axisEqual);
0053
0054
0055 i = 3;
0056 for t = tensions
0057
0058 args = {'DistanceType' demoOptions.DistanceType};
0059 if isfield(demoOptions.RBF.(rbfWithTensionType), 'PolynomialDegree') args = [args 'PolynomialDegree', demoOptions.RBF.(rbfWithTensionType).PolynomialDegree]; end
0060 args = [args, 'RBF', rbfWithTensionType];
0061 args = [args, 'RBFEpsilon', t];
0062 if isfield(demoOptions.RBF.(rbfWithTensionType), 'RBFEpsilonIsNormalized'), args = [args 'RBFEpsilonIsNormalized', demoOptions.RBF.(rbfWithTensionType).RBFEpsilonIsNormalized]; end
0063 if isfield(demoOptions.RBF.(rbfWithTensionType), 'Regularization'), args = [args 'Regularization' demoOptions.RBF.(rbfWithTensionType).Regularization]; end
0064
0065
0066 fprintf('- Interpolating using the Radial Basis Function Interpolant (%s kernel), with tension = %f...', rbfWithTensionType, t);
0067 tic;
0068 rbfInterp = RBFInterpolant(x, y, z, args{:});
0069 ziRBF = rbfInterp.interpolate(xi, yi);
0070 time = toc;
0071 fprintf(' done (%f seconds)\n', time);
0072 plotResult(x, y, z, xi, yi, ziRBF, spNumRows, spNumCols, i, [rbfWithTensionType ' with tension = ' num2str(t)], xLabel, yLabel, zLabel, axisEqual);
0073 i = i+1;
0074 end
0075 end