RunMat
GitHub

gca — Return the current axes handle in MATLAB and RunMat.

gca returns the handle for the current axes in the active figure. Optional struct mode returns a snapshot of current axes context for diagnostics and tooling.

Syntax

ax = gca()
s = gca('struct')

Inputs

NameTypeRequiredDefaultDescription
modeStringScalarYesOnly 'struct' is supported.

Returns

NameTypeDescription
axNumericScalarCurrent axes handle.
sAnyAxes state struct with handle/figure/rows/cols/index fields.

Errors

IdentifierWhenMessage
RunMat:gca:InvalidArgumentUnsupported arguments are provided.gca: unsupported arguments

How gca works

  • gca() returns a scalar numeric axes handle.
  • gca('struct') returns a struct with fields handle, figure, rows, cols, and index.
  • The current axes reflect the active subplot when subplot has been used.
  • Unsupported arguments raise gca plotting errors.

Does RunMat run gca on the GPU?

gca performs no provider dispatch; it only reads the active axes state from the plotting registry.

GPU memory and residency

gca returns host-side handles or structs and does not interact with GPU residency.

Examples

Read the current axes handle

figure(1);
ax = gca()

Expected output:

% ax is a numeric axes handle

Inspect the active subplot layout

subplot(2, 2, 3);
info = gca("struct")

Expected output:

info =
  struct with fields:
    handle
    figure
    rows
    cols
    index

Using gca with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how gca changes the result.

Run a small gca example, explain the result, then change one input and compare the output.

FAQ

What is special about gca('struct')?

It is a RunMat extension that returns a struct snapshot of the active axes state instead of just the encoded numeric handle.

Does gca reflect subplot selection?

Yes. When a subplot is active, gca reports that subplot's axes handle and metadata.

Does gca run on the GPU?

No. It only reads host-side plotting state.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · print · suptitle · xline · yline

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how gca is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.