www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgoptimexport/getInputExpression.m
function [pInputs, inputNames] = getInputExpression(obj, pOut, pPROJ, validOnly) %GETINPUTEXPRESSION Return named input expressions % % [PINPUTS, INPUTNAMES] = GETINPUTEXPRESSION(OBJ, pOUT, pPROJ) returns % pointers to the fixed and free variables in the optimization output % object, pointed by pOUT. The input pointers are located in the variable % dictionary of the CAGE project, pointed by pPROJ. Null pointers are % returned for any inputs that cannot be located. % % [PINPUTS, INPUTNAMES] = GETINPUTEXPRESSION(OBJ, pOUT, pPROJ, VALIDONLY) % returns the valid pointers to inputs only. % % See also CGOPTIMTABLEFILLER/GETRELATEDEXPRESSION % Copyright 2005-2006 The MathWorks, Inc. % Set the valid only flag if nargin < 4 validOnly = false; end % Get the inputs pD = getdd(pPROJ.info); inputNames = getColumnNames(pOut.info, ... 'OutputContents', {'FreeVars', 'FixedVars'}); pInputs = i_findInput(pD.info, inputNames); % Filter out the null pointers if required if validOnly idxValid = isvalid(pInputs); pInputs = pInputs(idxValid); inputNames = inputNames(idxValid); end %-------------------------------------------------------------------------- function ptr = i_findInput(ddnode, inputNames) %-------------------------------------------------------------------------- % Get all the pointers from the data dictionary and their names ptrlist = listptrs(ddnode); varNames = pveceval(ptrlist, @getname); % Initialise return ptr = mbcpointer(1, length(inputNames)); % Loop through to find the specified inputs. We are not checking aliases as % these will not have been used by the optimizer. for m = 1:length(inputNames) [unused, idx] = intersect(varNames, inputNames{m}); if isempty(idx) ptr(m) = null(xregpointer); else ptr(m) = ptrlist(idx); end end