www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptcsol/getSolutionData.m

    function data = getSolutionData(cgc, alldata)
%GETSOLUTIONDATA Return the data for the complete custom solution.
%
%  DATA = GETSOLUTIONDATA(CGC, ALLDATA) returns the data that has been
%  chosen as best by the user.  ALLDATA can be either a 3-D array or a cell
%  array of 3-D arrays.

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


UNWRAP_CELL = false;
if ~iscell(alldata)
    UNWRAP_CELL = true;
    alldata = {alldata};
end

sols = cgc.solutionNo;
data = cell(size(alldata));
if ~isempty(sols) && (length(sols)==size(alldata{1}, 1))
    data = cell(size(alldata));
    for n = 1:length(alldata)
        data{n} = i_extractselpage(alldata{n}, sols);
    end
end

if UNWRAP_CELL
    data = data{1};
end



function data = i_extractselpage(alldata, SelIdx)
data = alldata(:,:,1);
for n = 1:size(data,1)
    data(n,:,:) = alldata(n, :, SelIdx(n));
end