www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimextoptions/numVariables.m

    function [n, mn, mx] = numVariables(opts)
%NUMVARIABLES Get number of free variables in optimization
%
%  N = NUMVARIABLES(OPTS) gets the number of free variables that have
%  been defined in the optimization options.
%
%  [N, MIN, MAX] = NUMVARIABLES(OPTS) also returns the minimum and maximum
%  number of items that are allowed.

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


n = length(getFreeVariables(opts));

if nargout>1
    mode =  getFreeVariablesMode(opts);
    if strcmp(mode, 'any');
        mn = 1;
        mx = realmax;
    else
        mn = max(1,n);
        mx = max(1,n);
    end
end