time | Calls | line |
---|
| | 1 | function [isaxarray,outarr]=objArrayDispatch(func,varargin)
|
| | 2 | % This function is undocumented and may change in a future release.
|
| | 3 |
|
| | 4 | % Dispatches a function to multiple axes
|
| | 5 | % Copyright 2019 The MathWorks, Inc.
|
| | 6 |
|
0.008 | 94 | 7 | outarr=gobjects;
|
< 0.001 | 94 | 8 | isaxarray=false;
|
< 0.001 | 94 | 9 | args=varargin;
|
< 0.001 | 94 | 10 | isAllowed=@(obj)isa(obj,'matlab.graphics.axis.AbstractAxes') || ...
|
| | 11 | isa(obj,'matlab.graphics.chart.Chart') || ...
|
| | 12 | isa(obj,'matlab.graphics.layout.Layout') || ...
|
| | 13 | isa(obj,'matlab.graphics.illustration.Legend') || ...
|
| | 14 | isa(obj,'matlab.graphics.illustration.ColorBar') || ...
|
| | 15 | isa(obj,'matlab.ui.control.UIAxes');
|
| | 16 |
|
| | 17 | % Return if args/first arg is empty, or first arg is scalar or the first
|
| | 18 | % arg contains anything other than an axes/chart
|
0.009 | 94 | 19 | if isempty(args) || isempty(args{1}) || isscalar(args{1}) || ~any(arrayfun(isAllowed,args{1}),'all')
|
0.001 | 94 | 20 | return
|
| | 21 | end
|
| | 22 |
|
| | 23 | % Peel off axes array
|
| | 24 | axarr=args{1};
|
| | 25 | args(1)=[];
|
| | 26 | isaxarray=true;
|
| | 27 |
|
| | 28 | % Error for heterogeneous arrays
|
| | 29 | isHomogeneous=all(arrayfun(@(x)strcmp(class(x),class(axarr)),axarr));
|
| | 30 | if ~isHomogeneous
|
| | 31 | throwAsCaller(MException(message('MATLAB:rulerFunctions:MixedAxesVector')))
|
| | 32 | end
|
| | 33 |
|
| | 34 | % Loop over axarr
|
| | 35 | if nargout>1
|
| | 36 | % the calling function has an output
|
| | 37 | outarr=gobjects(size(axarr));
|
| | 38 | for i = 1:numel(axarr)
|
| | 39 | try
|
| | 40 | outarr(i)=func(axarr(i),args{:});
|
| | 41 | catch me
|
| | 42 | throwAsCaller(me)
|
| | 43 | end
|
| | 44 | end
|
| | 45 | else
|
| | 46 | for i = 1:numel(axarr)
|
| | 47 | try
|
| | 48 | func(axarr(i),args{:});
|
| | 49 | catch me
|
| | 50 | throwAsCaller(me)
|
| | 51 | end
|
| | 52 | end
|
| | 53 | end
|
| | 54 | end
|
Other subfunctions in this file are not included in this listing.