## How do I get the figure number in MATLAB R2014b?

### MathWorks Support Team (view profile)

on 7 Oct 2014
Latest activity Commented on by Steven Lord

### Steven Lord (view profile)

on 16 Aug 2017
Accepted Answer by MathWorks Support Team

### MathWorks Support Team (view profile)

How do I get the figure number in MATLAB R2014b?

R2014b

### MathWorks Support Team (view profile)

on 7 Oct 2014

Starting in MATLAB R2014b, figure handles are object handles where previously they were integers.  Now to get the associated number for the figure, query the new Number property. For example, this code gets the number for the current figure.
n = get(gcf,'Number')
n =
1
The Number property is the value displayed in the figure title bar.
You can refer to a figure by its integer number. For example, figure(2) makes the figure with a Number property value of 2 the current figure.

Matías Leonel Martini

### Matías Leonel Martini (view profile)

on 6 Apr 2017
Hi,
I use Matlab 13a. I puted code, and this returned:
>> figure
>> n = get(gcf,'Number')
n = on
No the figure number.
How can i get the figure number in matlab 13a?
Steven Lord

### Steven Lord (view profile)

on 16 Aug 2017
figure handles are object handles where previously they were integers. So in releases prior to R2014b, gcf returns a number not an object. The value 'on' that you receive is the value of the NumberTitle property of the figure.

### Massimo Ciacci (view profile)

on 16 Aug 2017
Edited by Massimo Ciacci

### Massimo Ciacci (view profile)

on 16 Aug 2017

For back-compatibility with versions previous to 2014b one can do the following
v = version('-release'); vn=str2double(v(1:4))*10+(v(5)-'a')+1;
if vn>=20142 %>= 2014b
FigNr = get(gcf,'Number');
else
FigNr = gcf;
end

Steven Lord

### Steven Lord (view profile)

on 16 Aug 2017
If you're using release R2007a or later, use verLessThan. If you're using release R2006b or earlier, you could try to use verLessThan and appropriately handle the case where you catch an error related to that call.