www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimdatasetfiller/cgoptimdatasetfiller.m
function obj = cgoptimdatasetfiller(varargin) %CGOPTIMDATASETFILLER Constructor for cgoptimdatasetfiller % % CGOPTIMDATASETFILLER is an object that exports optimization results to % a CAGE Data Set. % % OBJ = CGOPTIMDATASETFILLER creates an empty CGOPTIMDATASETFILLER % object. % % OBJ = CGOPTIMDATASETFILLER(pDATASET) creates a CGOPTIMDATASETFILLER % object which can export optimization results to the specified data set. % % OBJ = CGOPTIMDATASETFILLER(pDATASET, FILLACTION) determines what % happens when the specified data set is filled. Specifically, FILLACTION % must be one of the following options % FILLACTION = 1: Export data to a new data set % FILLACTION = 2: Append data to an existing data set % FILLACTION = 3: Overwrite an existing data set with data % % OBJ = CGOPTIMDATASETFILLER(pDATASET, FILLACTION, NEWDATASETNAME) sets % the name of the data set created if optimization results are exported % to a new data set. % % See also CGOPTIMTABLEFILLER % Copyright 2006 The MathWorks, Inc. % Construct the base class baseClass = cgoptimexport; % Create the properties s = i_createstruct; % Set any inputs if specified if nargin [ok, msg] = i_CheckInputs(varargin); if ok s.pDataset = varargin{1}; else error('mbc:cgoptimdatasetfiller:InvalidArgument', ... ['CGOPTIMDATASETFILLER : ',msg]); end end % Create the class obj = class(s, 'cgoptimdatasetfiller', baseClass); %-------------------------------------------------------------------------- function s = i_createstruct %-------------------------------------------------------------------------- % Create the default structure s = struct(... 'pDataset', null(xregpointer),... % Pointer to data set 'FillAction', 1, ...% Code to determine what to do when data set is filled. FillAction = 1: Create a new data set, FillAction = 2: Append to an existing data set, FillAction = 3: Overwrite an existing data set 'NewDatasetName', 'New_Dataset', ... % String to hold new data set name 'Version', 1); %-------------------------------------------------------------------------- function [ok, msg] = i_CheckInputs(in) %-------------------------------------------------------------------------- ok = true; msg = ''; % Check number of inputs nIn =length(in); if ~nIn return elseif ~ismember(nIn, 1:3) ok = false; msg = 'CGOPTIMTABLEFILLER accepts 0, 1, 2 or 3 input arguments'; return end % Check to see that the first input is a pointer to a data set [ok, msg] = pCheckDataset(in{1}); % Check to see that the second input is either 1, 2 or 3 if nIn < 2 return end [ok, msg] = pCheckFillAction(in{2}); % Check to see that the third input is a string if nIn < 3 return end [ok, msg] = pCheckNewDatasetName(in{3});