www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conbase/setMatchedFactors.m

    function con = setMatchedFactors(con, cif, ai)
%SETMATCHEDFACTORS Change the input factors for a constraint
%
%  CON = SETMATCHEDFACTORS(CON, CIF, AI)
%
%  This method is used to change the number and/or the order of input
%  factors for a constraint.  The new inputs must be matched to active
%  factors of the constraint before being set anew. Use the index AI to
%  specify this matching. See also GUIMATCHINPUTS for an example.
%
%  To change just the properties, i.e., names, symbols or ranges, of the
%  input factors then use the SETINPUTFACTORS method.
%
%  To change the number of active factors for a constraint, use then
%  SETACTIVEFACTORS method. For example, in a GUI to set-up a constraint,
%  use the SETACTIVEFACTORS to change the active factors.
%
%  See also CONBASE, CONINPUTFACTOR, 
%           CONBASE/SETINPUTFACTORS, 
%           CONBASE/SETACTIVEINDICES.

%  Copyright 2005-2011 The MathWorks, Inc.


% Check inpu factors
if ~isa( cif, 'coninputfactor' ),
    error(message('mbc:conbase:InvalidInput'));
end

if nargin>2
    % Ensure vector of active indices is the correct shape, i.e., a row
    ai = ai(:).';
    % Number of active factors cannot change
    if length( ai ) ~= length( con.ActiveFactors ),
        error( 'mbc:conbase:InvalidInput', ...
            'The number of active factors cannot change. Use SETACTIVEINDICES to change the number of active factors.' );
    end
    % Note that we don't call the setActiveIndices to set the active indices.
    % That method will usually perform some kind of reset on the parameters of
    % the constrait and we don't want to do that in this method.
    con.ActiveFactors = ai;
elseif length(cif)~=nFactors(con)
    error(message('mbc:conbase:InvalidArgument6'));
end
% Set new values
con.InputFactors  = cif;



%------------------------------------------------------------------------------|
% EOF
%------------------------------------------------------------------------------|