Access the contents of a mat file

Hi All,

I’ve saved a matrix in mat file and I’m trying to load and access the matrix in Julia.

file = matopen("mat1.mat")
varnames = keys(file)
println(varnames)
println(typeof(file))

mat1 = # how can I access the variable in file?

I tries something like this println(file["variable"]). I’m not sure what’s the right way.

Could someone please help me with this?

Hello, You can use matread

vars        = matread(joinpath("."mat1.mat"));
matVar =  vars["data"]; # Where "data" is the name of the variable you want to load
1 Like