www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@calibrationdata/@calibrationinterface/getItem.m
function item = getItem(obj, identifier, varargin) %GETITEM Get item from calibration. % % ITEM = GETITEM(CAL,IDENTIFIER) gets the items with identifier % IDENTIFIER from the calibration CAL. There are several caveats. Some % calibrations may allow items of different types to have identical % identifiers. In this case, GETITEM can return multiple items for a % single identifier. This means that there is no guaranteed % correspondence between identifiers and the items returned. For this % reason, multiple identifiers are reduced to a unique (and sorted) list % before items are retrieved. % % ITEM = GETITEM(CAL,IDENTIFIER,ITEMTYPE) gets only items of type % ITEMTYPE. % % See also GETAXIS, GETVALUE, GETCURVE, GETMAP. % Copyright 2004-2011 The MathWorks, Inc. narginchk(2,3) if ischar(identifier) identifier = {identifier}; elseif ~iscell(identifier) error(message('mbc:calibrationdata:calibration:InvalidArgument')) end switch nargin case 2 if ~all(obj.isItemIdentifier(identifier)) error(message('mbc:calibrationdata:calibration:ObjectNotFound')) else % Remove duplicate identifiers. (It's not possible to simply % call unique on the final list because getAxis etc return % copies of the items held in the calibration.) identifier = unique(identifier); % Initialize item = []; % Add any axes axisIdentifier = identifier(obj.isAxisIdentifier(identifier)); if ~isempty(axisIdentifier) item = [item; obj.getAxis(axisIdentifier)]; end % Add any values valueIdentifier = identifier(obj.isValueIdentifier(identifier)); if ~isempty(valueIdentifier) item = [item; obj.getValue(valueIdentifier)]; end % Add any curves curveIdentifier = identifier(obj.isCurveIdentifier(identifier)); if ~isempty(curveIdentifier) item = [item; obj.getCurve(curveIdentifier)]; end % Add any maps mapIdentifier = identifier(obj.isMapIdentifier(identifier)); if ~isempty(mapIdentifier) item = [item; obj.getMap(mapIdentifier)]; end end case 3 % Item type is provided itemType = varargin{1}; switch lower(itemType) case 'axis' item = obj.getAxis(identifier); case 'value' item = obj.getValue(identifier); case 'curve' item = obj.getCurve(identifier); case 'map' item = obj.getMap(identifier); otherwise error(message('mbc:calibrationdata:calibrationinterface:InvalidArgument2')) end otherwise % Impossible end