www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/@cglookuptwo/bpfill.m

    function [om,OK,msg]=bpfill(LT, sf)
%BPFILL
%
% creates an optimMgr for filling the breakpoints of LT
% These use the 'initialisation routines' that use curvature and errors
% [om, OK, msg] = bpfill(LT)
% [LT, cost, OK, msg] = run(om, LT, [],sf)

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


if ~isfill(LT)
    OK = 0;
    msg = 'The table is empty or incomplete.';
    om = [];
    return
end

tablename = getname(LT);

om = contextimplementation(xregoptmgr,LT,@i_bpfill,[],['FillBP_' tablename],@bpfill);

%flag for autospacing/initialising
om = AddOption(om,'FillMethod','ShareAveCurv','ShareAveCurv|ShareCurvThenAve', 'Fill method');

mod = get(sf, 'model');
if isempty(mod)
    om = [];
    OK = 0;
    msg = 'This subfeature has no model associated with it.';
    return
end


% are all the variables in the table also in the model?
[tableVariables , problemVar, otherVariables]= getvariables(LT,mod);

if ~isempty(problemVar)
    OK = 0;
    msg = problemVar;
    om = [];
    return
end

if ~isequal(length(tableVariables),2)
    om = [];
    OK = 0;
    msg = 'There must be two variables feeding into the table. ';
    return
end

tableVarObj = infoarray(tableVariables);
for i = 1:length(tableVariables)
    range = getrange(tableVarObj{i});
    om = AddOption(om, ['Range_' getname(tableVarObj{i})], range, {'range',[-Inf,Inf]}, ['Range ' getname(tableVarObj{i})]);
end

% Set other variables to their setpoints
varObj = infoarray(otherVariables);
for i = 1:length(otherVariables)
    val = getnomvalue(varObj{i});
    omi = omlinspace(varObj{i}, val, val, 1);
    om= AddOption(om,['Set_' getname(varObj{i})], omi, 'xregoptmgr', getname(varObj{i}));
end


OK = 1;
msg = '';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [LT,cost,OK, msg] = i_bpfill(LT,om,x0, sf)

method = get(om, 'FillMethod');
switch method
    case 'ShareAveCurv'
        [LT, cost, OK, msg] = BPinit_curv(LT,om,sf);
    case 'ShareCurvThenAve'
        [LT, cost, OK, msg] = BPinit_curv2(LT,om,sf);
    otherwise
        OK = 0;
        msg = 'Not a valid fill method. ';
        return
end