www.gusucode.com > mbc 工具箱 matlab 源码程序 > mbc/@mbcmodel/@testplan/AttachData.m
function D = AttachData(T, D, varargin) %ATTACHDATA Attach a data object to the testplan. % % D = ATTACHDATA( TESTPLAN, DATA, PROP, VALUE, ... ) % %This is a method of mbcmodel.testplan. Use it to attach the data you want %to model to the test plan. % % TESTPLAN is the mbcmodel.testplan object, % DATA is a mbcmodeldata object. % %If the test plan has responses set up the models are fitted when you %attach data. % %The 'UseDataRange' property changes the test plan input ranges to the %range of the data. % %There are a number of optional property/value pairs to control how the %data is matched to a design. These are the settings shown in the last page %of the Data Wizard (if there is a design) in the Model Browser. For more %information on the meaning of these settings, refer to the Data Wizard %section (under Data) in the Model Browser User's Guide. % % The complete list of property/value pairs for AttachData is: % Property Value Default % 'unmatcheddata' {'all', 'none'} 'none' % 'moredata' {'all', 'closest'} 'closest' % 'moredesign' {'none', 'closest'} 'none' % 'tolerances' 1xNumInputs double ModelRange/20 % 'usedatarange' logical false % %When you attach data to a test plan the Name property of the test plan %inputs is used to select data channels. If the Name is empty then the %Symbol property is used as the data channel name. If the Name does not %exist in the data set, an error is generated. % %When a test plan has data attached, it is only possible to change the %symbols, ranges or nonlinear transforms of the test plan inputs. % %Examples: % % To use all the data in DATA in the test plan TESTPLAN and set the input % ranges to the data range: % newD = AttachData(TESTPLAN, DATA,'usedatarange',true); % %To match DATA to the best design in TESTPLAN within specified tolerances: % tol = [0.075, 100, 1, 2]; % unmatch = 'all'; % moredata = 'all'; % moredes = 'none'; % AttachData(TESTPLAN, DATA ,... % 'tolerances', tol,... % 'unmatcheddata', unmatch,... % 'moredata', moredata,... % 'moredesign', moredes); % %You can use AttachData to use data from one project in another project: % p1 = mbcmodel.LoadProject( filename ); % p2 = mbcmodel.LoadProject( filename2 ); % p1.Testplan.AttachData( p2.Data(1) ); % Copyright 2004-2009 The MathWorks, Inc. error(mbcnargchk(2, inf, nargin, 'mbc:mbcmodel:testplan')); % Make sure that we have been given the correct type of object if ~isa(D, 'mbcmodel.data') error('mbc:mbcmodel:testplan:InvalidArgument', ... 'Only mbcmodel.data objects may be attached to a testplan'); end % Make sure that the data is not being edited if D.IsBeingEdited error('mbc:mbcmodel:testplan:InvalidState', ... 'CommitEdit must be called on data before it is attached to a testplan'); end try % Get the mdevproject object MP = info(project(T.Object)); % Is the data external to the project if ~ismember(D.pGetPointerInstance, dataptrs(MP)) % Make a deep copy pData = xregpointer(copy(D.Object)); % Add the pointer to the project addData(MP, pData); else pData = D.pGetPointerInstance; end % If the data is currently external to te project % Attach the requested data to the testplan pD = attachData(T.Object, pData, varargin{:}); % Return an mbcmodel.data object D = mbcmodel.data(pD, T); % clear boundary tree object if ~isempty(T.pBoundary) && isvalid(T.pBoundary) delete(T.pBoundary) T.pBoundary = []; end catch E mnemonic = mbcGetLastError(E); error(['mbc:mbcmodel:testplan:' mnemonic], E.message); end