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

    function p = cgnormaliser(name,varargin)
%CGNORMALISER
%
%  Constructor for the cgnormaliser class.
%	n=CGNORMALISER returns an empty lookUpOne object.
%	n=CGNORMALISER(name,M,X,v) returns a xregpointer to a cgnormaliser
%	object.
%		M - lookup table values 			- [n 2] array of doubles
%		X - input argument of the table 	- xregpointer to expression
%		v - clip points  						- [cliplow,cliphigh] doubles 
%  The breakpoints field will be the first column of M and the values field
%  will be the second column of M. 
%  Method flist will be called when another LUT has one of its argument
%  fields filled with a xregpointer to this table.

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

N = struct('Breakpoints',[],...
   'Values',[],...
   'Xexpr',[],...
   'BPLocks',[],...
   'VLocks',[],...
   'Memory',cgNormaliserHistory.empty(1,0),...
   'Flist',[],...
   'SFlist',[],...
   'Weights',[],...
   'Description',[],...
   'Input',[],...
   'Precision',cgprecfloat('double'),...
   'Extrapolate',0, ...
   'Version', 3);

e = cglookup;

if nargin ==0;
   p = class(N,'cgnormaliser',e);
   return
end

if ischar(name)
   e = setname(e,name);
else
   error(message('mbc:cgnormaliser:InvalidArgument'));
end

if ~isempty(varargin)
   % Parse data values
   data = varargin{1};
   N.Breakpoints = data(:,1);
   N.Values = data(:,2);
   N.BPLocks = zeros(size(data(:,1)));
   N.VLocks = zeros(size(data(:,2)));
   info = 'Initial configuration';
   % Parse 
   
   if length(varargin)==2
      if isa(varargin{2},'xregpointer')
         if isa(varargin{2}.info,'cgexpr')
            N.Xexpr = varargin{2};
         else
            error(message('mbc:cgnormaliser:InvalidArgument1'));
         end
      else
         error(message('mbc:cgnormaliser:InvalidArgument2'));
      end
   end
else
   info = 'Created';
end
% Create object class and assign xregpointer
N = class(N,'cgnormaliser',e);
N.Memory = cgNormaliserHistory(N,info);
p = xregpointer(N);