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

    function SubFlags = pGetFlagData(obj, Flags, Runs, Sols)
%PGETFLAGDATA Get specified flags.
%
%   PGETFLAGDATA(OUT, FLAGS, RUNS, SOLS) returns the specified sub-index of
%   the flag data in flags. RUNS and SOLS may be either vectors of indices,
%   logical vectors or the character ':' to indicate all runs or solutions.
%   If they are vectors of indices then an index of -1 will be taken to
%   indicate that the selected solution should be used for each run for
%   that column.

%   Copyright 2006 The MathWorks, Inc.

idxSel = (Sols == -1);

if any(idxSel)
    nR = getNumRuns(obj);
    nS = getNumSolutions(obj);

    % Convert all of the input options down to a common type of an index vector
    if ischar(Runs) && strcmp(Runs, ':')
        Runs = 1:nR;
    elseif islogical(Runs)
        Runs = find(Runs);
    end

    % Find indices of selected solutions and set these to the first solution
    % for now
    Sols(idxSel) = 1;

    % Simple index operation to get normal-indexed solutions plus placeholders
    % for the selected solutions
    SubFlags = Flags(Runs, Sols);

    % Insert flags for selected solutions
    SolIndex = getSelectedSolutionNumber(obj, Runs);
    SubFlags(:, idxSel) = repmat(Flags(sub2ind([nR, nS], Runs(:), SolIndex(:))), 1, sum(idxSel));
else
    SubFlags = Flags(Runs, Sols);
end