matfile — Create a MAT-file object for whole-variable reads and writes.
matfile(filename) returns a matlab.io.MatFile compatibility object. RunMat supports m.Properties, whole-variable dot reads such as m.A, and whole-variable dot assignment when the object is constructed with 'Writable', true.
Syntax
matfile(filename)Options
Writableaccepts a scalar logical or numeric value. When false or omitted, dot assignment through the object is rejected.m.Propertiesreturns a struct containingSourceandWritable.- Dot reads load a complete variable from the MAT-file, preserving the existing
loadbuiltin's Level-5 MAT-file type support.
GPU memory and residency
matfile is host file I/O. GPU-resident assignment values are gathered before MAT-file serialization.
Examples
Read a whole variable
m = matfile('data.mat');
A = m.A;Expected output:
A contains the variable loaded from data.mat.Write whole variables
m = matfile('data.mat', 'Writable', true);
m.A = rand(3);
m.flag = true;Expected output:
The MAT-file is rewritten with updated whole variables.Using matfile with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how matfile changes the result.
Run a small matfile example, explain the result, then change one input and compare the output.
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 · open · 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
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.