MAT.jl Documentation
Overview
This Julia package (MAT.jl) provides tools for reading and writing MATLAB format data files in Julia.
Basic Usage
To read a single variable from a MAT file (compressed files are detected and handled automatically):
using MAT
file = matopen("matfile.mat")
read(file, "varname") # note that this does NOT introduce a variable ``varname`` into scope
close(file)To write a variable to a MAT file:
file = matopen("matfile.mat", "w")
write(file, "varname", variable)
close(file)To read all variables from a MAT file as a Dict:
vars = matread("matfile.mat")To write a Dict to a MAT file, using its keys as variable names. The compress argument is optional, and compression is off by default:
matwrite("matfile.mat", Dict(
"myvar1" => 0,
"myvar2" => 1
); compress = true)To write in MATLAB v4 format:
matwrite("matfile.mat", Dict(
"myvar1" => 0,
"myvar2" => 1
);version="v4")To get a list of variable names in a MAT file:
file = matopen("matfile.mat")
varnames = keys(file)
close(file)To check for the presence of a variable name in a MAT file:
file = matopen("matfile.mat")
if haskey(file, "variable")
# something
end
close(file)