saveas — Save a figure to a file.

saveas(fig, filename) saves the specified figure or graphics object parent figure. RunMat supports RunMat FIG scene files and PNG image export.

Syntax

ok = saveas(fig, filename)
ok = saveas(fig, filename, formattype)

Inputs

NameTypeRequiredDefaultDescription
argsAnyVariadicMATLAB-compatible figure persistence arguments.

Returns

NameTypeDescription
okLogicalArrayTrue when the save operation completed.

Errors

IdentifierWhenMessage
RunMat:figurePersistence:InvalidArgumentArguments are missing, malformed, or incompatible with the requested figure persistence operation.figure persistence: invalid argument
RunMat:figurePersistence:UnsupportedFormatThe requested save/load format is recognized but not supported by RunMat's active plotting exporter.figure persistence: unsupported format
RunMat:figurePersistence:IoFailureThe target file cannot be read, written, flushed, synced, or atomically replaced.figure persistence: file I/O failed

How saveas works

  • saveas(fig, filename) infers the output format from .fig or .png; names without an extension save as .fig.
  • saveas(fig, filename, formattype) uses the explicit format. If filename has no extension, RunMat appends the standard extension for that format.
  • Figure, axes, text, legend, ruler, and plot-child handles save their parent figure.
  • PDF, EPS, SVG, JPEG, TIFF, and MATLAB code-generation formats are recognized as unsupported until those exporters exist.

Does RunMat run saveas on the GPU?

PNG export uses the same renderer path as print.

FIG export serializes plotting state through the replay scene exporter.

Unsupported export formats fail before any partial output is written.

GPU memory and residency

saveas is an I/O sink. It returns a host logical status and does not launch numeric GPU kernels.

Examples

Save a figure scene

plot(1:5, [1 4 2 5 3]);
saveas(gcf, "plot_state.fig");

Save a PNG image

plot(0:0.1:1, (0:0.1:1).^2);
saveas(gcf, "quadratic", "png");

Using saveas with coding agents

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

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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how saveas 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.