demoRBFInterpolantWithTension

PURPOSE ^

demoRBFInterpolants Simple script showing the different RBF interpolants available in the toolbox.

SYNOPSIS ^

function demoRBFInterpolantWithTension(dataId, rbfWithTensionType, tensions)

DESCRIPTION ^

demoRBFInterpolants Simple script showing the different RBF interpolants available in the toolbox.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function demoRBFInterpolantWithTension(dataId, rbfWithTensionType, tensions)
0002 %demoRBFInterpolants Simple script showing the different RBF interpolants available in the toolbox.
0003 
0004     %% Parse parameters
0005     if nargin < 1 || isempty(dataId)
0006         dataId = 'seamount';
0007     end
0008 
0009     if nargin < 2
0010 %         rbfWithTensionType = 'greenregularizedwithtension';
0011         rbfWithTensionType = 'greenwithtension';
0012     end
0013 %     if ~strcmp(rbfWithTensionType, 'tensionspline') && ~strcmp(rbfWithTensionType, 'regularizedspline')
0014 %         error('Only tensionspline and regularizedspline RBF depend on the tension parameter');
0015 %     end
0016     
0017     %% Get the sample data and options
0018     [x, y, z, xi, yi, zt, demoOptions] = getSampleDataset(dataId);
0019     
0020     % Normalize 0..1
0021 %     x = NormalizeValuesInRange(x, min(x(:)), max(x(:)), 0, 1);
0022 %     y = NormalizeValuesInRange(y, min(y(:)), max(y(:)), 0, 1);
0023 %     z = NormalizeValuesInRange(z, min(z(:)), max(z(:)), 0, 1);
0024 %     xi = NormalizeValuesInRange(xi, min(xi(:)), max(xi(:)), 0, 1);
0025 %     yi = NormalizeValuesInRange(yi, min(yi(:)), max(yi(:)), 0, 1);
0026 %
0027 %     % Convert to a projected coordinate system
0028 %     [x,y]=llutm84(y, x, 0);
0029 %     [xi,yi]=llutm84(yi, xi, 0);
0030 
0031     % The tension parameters to test
0032     if nargin < 3
0033 %         tensions = [0.1, 1, 10, 100, 1000, 10000];
0034         tensions = 0.1:0.1:0.9;
0035     end
0036     spNumCols = 4;
0037     spNumRows = ceil((numel(tensions)+2) / spNumCols);
0038     
0039     %% Show the original function evaluated on the grid, if available
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         % Print a text in the subplot location?
0049     end
0050     
0051     %% Prepare show the scattered input data
0052     plotResult(x, y, z, [], [], [], spNumRows, spNumCols, 2, 'Input Samples', xLabel, yLabel, zLabel, axisEqual);
0053  
0054     %% Apply the RBF interpolant with all the RBF definitions available
0055     i = 3;
0056     for t = tensions
0057         % Setup varargin
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         % Create and query the interpolant
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

Generated on Thu 10-Dec-2020 17:34:27 by m2html © 2005