1

Mathworks has done it again: my ancient R2012 (as bestowed by my company) returns a nice set of doubles identifying the figure window numbers in response to

currhandles=findall(0,'type','figure');

Now I got a fellow remotely IM-ing me 'cause the code I gave him fails under R2015 because findall now returns a structure for the figure handle. I can't play w/ his system (no RDC) and the mathworks documentation pages don't appear to specify the elements of the figure handle structure. In particular, I'd like to know if I can still retrieve the figure window number. Anyone know?

Luis Mendo
  • 110,752
  • 13
  • 76
  • 147
Carl Witthoft
  • 20,573
  • 9
  • 43
  • 73
  • 1
    See: [Graphics Handles Are Now Objects, Not Doubles](http://www.mathworks.com/help/matlab/graphics_transition/graphics-handles-are-now-objects-not-doubles.html). [Loren's blog post](http://blogs.mathworks.com/loren/2014/10/14/matlab-r2014b-graphics-part-2-using-graphics-objects/) on the topic expands on this as well. – sco1 Aug 13 '15 at 19:04

1 Answers1

3

Of course.

currhandles(:).Number

will return all numbers as a comma-separated list.

Or specify a number you want:

currhandles(1).Number

The order appears to be the inverse order of initialization.


Alternatively you can define two anonymous functions to get an array directly:

figure(1); figure(2); figure(42);

getNumbers = @(x) [x.Number];
getFigureNumbers = @() getNumbers([findall(0,'type','figure')]);

getFigureNumbers()

ans =

    42     2     1
Robert Seifert
  • 25,078
  • 11
  • 68
  • 113