How to find out how many digits are currently open?

Is there a way to find out how many digits are open in Matlab?

+6
source share
2 answers

Using:

numel(get(0,'Children')); 

You can also use what @triazotan suggested using the findobj function. However, this will be slower because you need to go through all your objects.

Edit: I decided to see how findobj works. This is a much more complicated way to go through all the objects in get (0, "Children")
Here is a small digest from the file that is called from findobj : Check the built-in ('get', 0, 'ShowHiddenHandles') , which essentially is get (0, 'Children') in the middle:

 function h = findobjhelper( varargin ) %Copyright 2009-2010 The MathWorks, Inc. allowHVHandles = true; nin = nargin; rootHandleVis = builtin( 'get', 0, 'ShowHiddenHandles' ); % See if 'flat' keyword is present hasflat = false; if (nin > 1) if strcmp( varargin{2}, 'flat' ) % Does the 'flat' keyword exist hasflat = true; end end if nin == 0 if feature('HgUsingMatlabClasses') h = findobjinternal( 0, '-function', @findobjfilter ); else h = findobjinternal(0); end 

So using findobj is clearly redundant.

+8
source

I do not know the direct path, but you can try:

 length(findobj('Type','figure')) 

(i.e. the number of figure handlers returned by findobj )

+3
source

Source: https://habr.com/ru/post/905526/


All Articles