www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimoutput/private/pSetFlagData.m
function Flags = pSetFlagData(obj, Flags, Runs, Sols, SubFlags) %PSETFLAGDATA Get specified flags. % % PSETFLAGDATA(OUT, FLAGS, RUNS, SOLS, SUBFLAGS) sets the specified % sub-index of the flag data into 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 remove these idxSel = (Sols == -1); Sols(idxSel) = []; % Simple index operation to get normal-indexed solutions plus placeholders % for the selected solutions Flags(Runs, Sols) = SubFlags(:, ~idxSel); % Insert flags for selected solutions SolIndex = getSelectedSolutionNumber(obj, Runs); Flags(sub2ind([nR, nS], Runs, SolIndex)) = SubFlags(:, find(idxSel,1,'last')); else Flags(Runs, Sols) = SubFlags; end