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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
name | StringScalar | Yes | — | File or variable name to open. |
Returns
| Name | Type | Description |
|---|---|---|
A | Any | MAT-file contents, extension-handler output, figure handle, or empty array. |
Returned values from open depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:open:ArgumentCount | The call does not provide exactly one input argument. | open: expected exactly one input argument |
RunMat:open:InvalidName | The name is not a string scalar or row character vector. | open: name must be a character vector or string scalar |
RunMat:open:NotFound | No matching variable or file can be resolved. | open: file or variable was not found |
RunMat:open:UnsupportedFileType | The resolved file type cannot be opened by RunMat and no extension handler exists. | open: unsupported file type |
RunMat:open:HandlerFailed | A custom open<extension> handler fails. | open: extension handler failed |
RunMat:open:TooManyOutputs | The call requests more than one output. | open: expected at most one output |
How open works
open nameandA = 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
.logcan dispatch toopenlog. - MAT-files are decoded through the same implementation as
loadand return a scalar struct with one field per variable. .figfiles 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 setupExpected 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.
Related Io functions
Repl Fs
addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · mkdir · movefile · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite
Tabular
arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtimetable · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines
Import
Json
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how open is executed, line by line, in Rust.
- View the source for open in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
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.