www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/+cgfillsetup/private/pGetFillFns.m

    function [fillfn, fillfnnames] = pGetFillFns
%PGETFILLFNS Return all the available table filling functions
%
%  [FILLFN, FILLFNNAMES] = PGETFILLFNS returns the available table filling
%  functions, FILLFN, and their names, FILLFNNAMES.

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


% Get the possible fill functions. 

% Get the core functions
fillfn = {@pExtrapolateFill, @pDirectFill};
fillfnnames = {'Extrapolate Fill', 'Direct Fill'};

% Get any fill functions specified in extensions - should run the check
% method on them here.
cge = mbcextensions.Extensions.Cage;
extrafillfn = cge.OptimizationTableFillingFunctions;
nExt = size(extrafillfn, 1);
bExt = false(1, nExt);
for i = 1:nExt
    bExt(i) = pCheckFillFn(extrafillfn{i, 2});
end   
if nExt
    fillfn = [fillfn, extrafillfn(bExt, 2)];
    fillfnnames = [fillfnnames, extrafillfn(bExt, 1)];
end

% Get any fill functions registered by the user from previous fills. Filter
% out those that are now invalid.
p = mbcprefs('mbc');
tpref = getpref(p, 'Tables');
nCustom = length(tpref.FillFunctions);
bCustom = false(1, nCustom);
for i = 1:nCustom
    bCustom(i) = pCheckFillFn(tpref.FillFunctions{i});
end
if nCustom
    tpref.FillFunctions = tpref.FillFunctions(bCustom);
end

% Set the valid fill functions in MBC prefs
setpref(p, 'Tables', tpref);

% Return the function names and handles of the valid custom fill functions
fillfn = [fillfn, tpref.FillFunctions];
newfillfnnames = cellfun(@i_getFillFnNames, tpref.FillFunctions, ...
    'UniformOutput', false);
fillfnnames = [fillfnnames, newfillfnnames];

%--------------------------------------------------------------------------
function fillfnname = i_getFillFnNames(fillFunction)
%--------------------------------------------------------------------------

fhstr = functions(fillFunction);
[unused, fillfnname] = fileparts(fhstr.file);