gusucode.com > bigdata 工具箱 matlab源码程序 > bigdata/+matlab/+bigdata/+internal/+util/axesCheck.m
function [ax,args,nargs] = axesCheck(varargin) %AXESCHECK Process Axes objects from input list % This version is updated from the original to cope with tall inputs. % Copyright 1984-2016 The MathWorks, Inc. args = varargin; nargs = nargin; ax=[]; % Check for either a scalar Axes handle, or any size array of decendents % from the primitive Group. % 'ishghandle' will catch numeric graphics handles, but will not catch % deleted graphics handles, so we need to check for both separately. if (nargs > 0) && ... ((isNonTallScalar(args{1}) && ishghandle(args{1},'axes')) ... || isa(args{1},'matlab.graphics.axis.AbstractAxes')) ax = handle(args{1}); args = args(2:end); nargs = nargs-1; end if nargs > 0 inds = find(strcmpi('parent',args)); if ~isempty(inds) inds = unique([inds inds+1]); pind = inds(end); % Check for either a scalar handle, or any size array of graphics objects. % If the argument is passed using the 'Parent' P/V pair, then we will % catch any graphics handle(s), and not just Axes. if nargs >= pind && ... ((isNonTallScalar(args{pind}) && ishghandle(args{pind})) ... || isa(args{pind},'matlab.graphics.Graphics')) ax = handle(args{pind}); args(inds) = []; nargs = length(args); end end end % Make sure that the graphics handle found is a scalar handle, and not an % empty graphics array or non-scalar graphics array. if (nargs < nargin) && ~isscalar(ax) throwAsCaller(MException(message('MATLAB:graphics:axescheck:NonScalarHandle'))); end % Throw an error if a deleted graphics handle is detected. if ~isempty(ax) && ~isvalid(ax) % It is possible for a non-Axes graphics object to get through the code % above if passed as a Name/Value pair. Throw a different error message % for Axes vs. other graphics objects. if(isa(ax,'matlab.graphics.axis.AbstractAxes')) throwAsCaller(MException(message('MATLAB:graphics:axescheck:DeletedAxes'))); else throwAsCaller(MException(message('MATLAB:graphics:axescheck:DeletedObject'))); end end function tf = isNonTallScalar(x) % Helper for correctly finding non-tall scalar inputs tf = ~istall(x) && isscalar(x);