open — Open a file or variable using MATLAB-compatible dispatch.

open(name) resolves a workspace variable or file name using RunMat's MATLAB-style search path. MAT-files are loaded and returned as a struct, RunMat figure scene payloads return a figure handle, custom open<extension> handlers are invoked when available, and ordinary editor/viewer file types succeed with an empty result in noninteractive hosts.

Syntax

open name
A = open(name)

Inputs

NameTypeRequiredDefaultDescription
nameStringScalarYesFile or variable name to open.

Returns

NameTypeDescription
AAnyMAT-file contents, extension-handler output, figure handle, or empty array.

Returned values from open depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:open:ArgumentCountThe call does not provide exactly one input argument.open: expected exactly one input argument
RunMat:open:InvalidNameThe name is not a string scalar or row character vector.open: name must be a character vector or string scalar
RunMat:open:NotFoundNo matching variable or file can be resolved.open: file or variable was not found

How open works

  • open name and A = open(name) accept a string scalar or row character vector.
  • Workspace variable names are accepted as editor-style opens and return an empty 0-by-0 array.
  • Names without an extension are searched on the current RunMat path using MATLAB-like file extensions.
  • Names with an explicit extension are first searched exactly on the current RunMat path so custom extensions such as .log can dispatch to openlog.
  • MAT-files are decoded through the same implementation as load and return a scalar struct with one field per variable.
  • .fig files first try RunMat figure-scene import and return a numeric figure handle when successful; otherwise RunMat decodes them as MAT-file containers until full MATLAB figure reconstruction is available.
  • For non-MAT files, RunMat looks for a semantic handler named open<extension> and passes the resolved file path as a string.
  • Known text, script, project/model, document, toolbox/install, executable, and spreadsheet file extensions open as no-op viewer/editor requests and return an empty 0-by-0 array.
  • Requesting more than one output raises RunMat:open:TooManyOutputs.
  • Unsupported file types without a handler raise RunMat:open:UnsupportedFileType.

Does RunMat run open on the GPU?

open is an I/O dispatcher and does not participate in GPU fusion or provider-native execution.

Examples

Load a MAT-file through open

S = open('results.mat')

Expected output:

% S is a struct containing the variables stored in results.mat.

Open a script from the current path

open setup

Expected output:

% setup.m is resolved and treated as an editor/viewer open.

Open a figure scene

h = open('plot.fig')

Expected output:

% h is a figure handle when plot.fig contains a RunMat figure scene payload.

Dispatch to a custom extension handler

function out = openabc(filename)
    out = fileread(filename);
end
out = open('payload.abc')

Expected output:

% openabc receives the resolved filename and returns its output.

Using open with coding agents

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

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

FAQ

Does open launch a desktop editor or external application?

No. RunMat's runtime implementation is host-safe and noninteractive. It resolves the target and performs data-returning work where possible; viewer/editor opens complete as no-ops.

How is open('file.mat') different from load('file.mat')?

For MAT-files, open returns the same struct-style data that load returns when called with one output.

Can user code customize how an extension opens?

Yes. Define a function named open followed by the lowercase extension, for example openabc for .abc files. RunMat calls that handler with the resolved filename.

Open-source implementation

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