gca
Returns the handle of the current axes, creating one if needed.
Category: Graphics > Graphics Objects
Syntax
ax = gca
Returns the current axes of the current figure.
Description
Most plotting commands act on the current axes. gca gives you a handle to it, so you can use dot notation (ax.XLim = [0 5]) or get and set. If there is no figure or axes yet, one is created.
Output arguments
ax- Axes object, used to read or set properties such as limits and labels.
Example
Read and change axes properties
plot(1:3)
ax = gca;
ax.XLim = [0 5];
disp(ax.XLim)
disp(get(ax, 'Type'))
Output
0 5
axes