www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/+mbcboundary/Fit.m
function B = Fit(X,Type,varargin) %FIT fit boundary model % B = Fit(X,Type); % B = Fit(X); % B = Fit(X,Type,property1,value1,...); % Fit a boundary model to some data X. The input ranges of the boundary % model are determined from the data. The data must be a matrix with one % column for each input to the boundary model. The default for Type is % 'Range' for single column data or 'Star-shaped' otherwise. % %See also Model % Copyright 2009-2011 The MathWorks, Inc. narginchk(1,Inf) if ~isa(X,'double') || ndims(X)~=2 error(message('mbc:mbcboundary:InvalidValue')); end % create an input object using the data range Inputs = mbcmodel.modelinput(size(X,2)); for i=1:length(Inputs) if size(X,1)>0 R = [nanmin(X(:,i)), nanmax(X(:,i))]; if R(1)==R(2) R = [R(1)-1 R(2)+1]; end Inputs(i).Range = R; end end if nargin<2 switch length(Inputs) case 1 Type = 'Range'; otherwise Type = 'Star-shaped'; end end % create a command-line boundary model B = mbcboundary.CreateBoundary(Type,Inputs,varargin{:}); % fit the boundary model B = Fit(B,X);