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-2020 The MathWorks, Inc.
|
| | 6 |
|
0.002 | 5 | 7 | outarr=gobjects;
|
< 0.001 | 5 | 8 | isaxarray=false;
|
< 0.001 | 5 | 9 | args=varargin;
|
< 0.001 | 5 | 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 |
|
| | 16 | % Return if args/first arg is empty, or first arg is scalar or the first
|
| | 17 | % arg contains anything other than an axes/chart
|
0.002 | 5 | 18 | if isempty(args) || isempty(args{1}) || isscalar(args{1}) || ~any(arrayfun(isAllowed,args{1}),'all')
|
< 0.001 | 5 | 19 | return
|
| | 20 | end
|
| | 21 |
|
| | 22 | % Peel off axes array
|
| | 23 | axarr=args{1};
|
| | 24 | args(1)=[];
|
| | 25 | isaxarray=true;
|
| | 26 |
|
| | 27 | % Error for heterogeneous arrays
|
| | 28 | isHomogeneous=all(arrayfun(@(x)strcmp(class(x),class(axarr)),axarr), 'all');
|
| | 29 | if ~isHomogeneous
|
| | 30 | throwAsCaller(MException(message('MATLAB:rulerFunctions:MixedAxesVector')))
|
| | 31 | end
|
| | 32 |
|
| | 33 | % Loop over axarr
|
| | 34 | if nargout>1
|
| | 35 | % the calling function has an output
|
| | 36 | outarr=gobjects(size(axarr));
|
| | 37 | for i = 1:numel(axarr)
|
| | 38 | try
|
| | 39 | outarr(i)=func(axarr(i),args{:});
|
| | 40 | catch me
|
| | 41 | throwAsCaller(me)
|
| | 42 | end
|
| | 43 | end
|
| | 44 | else
|
| | 45 | for i = 1:numel(axarr)
|
| | 46 | try
|
| | 47 | func(axarr(i),args{:});
|
| | 48 | catch me
|
| | 49 | throwAsCaller(me)
|
| | 50 | end
|
| | 51 | end
|
| | 52 | end
|
| | 53 | end
|
Other subfunctions in this file are not included in this listing.