www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimrunner/private/pCopyDataSets.m

    function DSstatic = pCopyDataSets(obj, pFact, pDS, pAllInp)
%PCOPYDATASETS Copy data from a list of datasets
%
%  DATA = PCOPYDATASETS(OBJ, PFACT, P_DS, P_INP) extracts data and the
%  associated factor pointers from a list of pointers to cgoppoint objects.
%  DATA is a struct array of the same length as P_DS.  Each element of DATA
%  contains the fields Data, FixedVariableIdx and MatchedColumnIdx.
%
%  PFACT is a cell array of item pointers that have been matched
%  to the variable labels for that data set.

%  Copyright 2005-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.



opps = infoarray(pDS);
DSstatic = cell(1,length(pDS));
for n = 1:length(pDS)
    % Only need to copy the data columns that are inputs to the optim or
    % have labels specified for their columns.
    
    pF = get(opps{n}, 'ptrlist');
    D = get(opps{n}, 'Data');
    
    % Find columns we want to take
    ReqIdx = findptrs(unique([pFact{n}, pAllInp]), pF);
    ReqIdx = ReqIdx(ReqIdx>0);
    
    pF = pF(ReqIdx);
    Data = D(:, ReqIdx);
    FixedVarIdx = findptrs(pF, pAllInp);
    MatchedColIdx = findptrs(pFact{n}, pF);
    DSstatic{n} = cgstaticdataset(Data,FixedVarIdx,MatchedColIdx);
end