www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimtablefiller/private/pExtrapolateFill.m

    function [ok, newtabdata, fillmask] = pExtrapolateFill(varargin)
%PEXTRAPOLATEFILL Fill table using an extrapolating-RBF
%
%  [OK, NEWTABDATA, FILLMASK] = PEXTRAPOLATEFILL(COL, ROW, FILLDATA,
%  COLAXIS, ROWAXIS, CURRTABDATA) fills the 2-d table specified by the
%  axes, COLAXIS, ROWAXIS and with current table values, CURRTABDATA. An
%  extrapolating-RBF is used to fill the table. The data for the fill is
%  specified by the three vectors, row coordinate, ROW, column coordinate,
%  COL and table value, FILLDATA. If the fill was successful, OK is
%  returned as TRUE, the filled table is returned in NEWTABDATA and a
%  logical FILLMASK denoting the cells to be added to the table's
%  extrapolation mask is returned.
%
%  [OK, NEWTABDATA, FILLMASK] = PEXTRAPOLATEFILL(ROW, FILLDATA, ROWAXIS,
%  CURRTABDATA) fills the 1-d table specified by the axis, ROWAXIS and with
%  current table values, CURRTABDATA. An extrapolating-RBF is used to fill
%  the table. The data for the fill is specified by the two vectors, row
%  coordinate, ROW, and table value, FILLDATA. If the fill was successful,
%  OK is returned as TRUE, the filled table is returned in NEWTABDATA and a
%  logical FILLMASK denoting the cells to be added to the table's
%  extrapolation mask is returned.
%
%  See also PDIRECTFILL

%  Copyright 2005-2006 The MathWorks, Inc. and Ford Global Technologies, Inc.


% Get inputs from varargin
in = varargin;
[ok, filldata, axes, unused, NDIM] = pExtractTableFillingInputs(in);
if ~ok
    return
end

% Assume all will go OK
ok = true;

switch NDIM
    case 2
        % 2D table
        
        % Do the extrapolation
        newtabdata = eval(cgmathsobject,'extrapolate_RBF', ...
            filldata(:,1), filldata(:, 2), filldata(:,3), axes{1}, axes{2});
        
        % Fill mask is the cells in the data used to fill the table that
        % match table cells
        [unused, locind]  = pFindCellsInTable(axes, filldata(:, [1 2]));
        fillmask = zeros(size(newtabdata));
        fillmask(locind) = 1;

    case 1
        % 1D Table
        
        % Get fill data
        [xpts, xi] = unique(filldata(:,1)');
        ypts = filldata(xi, 2);
        
        % Do the extrapolation
        newtabdata = eval(cgmathsobject,'extinterp1',xpts,ypts, axes{1}(:));

        % Fill mask is the cells in the data used to fill the table that
        % match table cells
        [unused, locind] = pFindCellsInTable(axes, filldata(:, 1));
        fillmask = zeros(size(newtabdata));
        fillmask(locind) = 1;
        
    otherwise
        % We shouldn't get here - 0 > NDIM > 2 which isn't allowed
        ok = false;
        newtabdata = [];
        fillmask = [];
        return;
end