How to read variables of .mat in Julia?

I have installed MAT.jl package to read variables from .mat file.

When I use the following syntax. I got the error. How to resolve it?

using MAT

file = matopen("subject3455session6.mat")

read(file, "varname")
close(file)

Info: Precompiling MAT [23992714-dd62-5051-b70f-ba57cb901cac]
└ @ Base loading.jl:1260
WARNING: could not import HDF5.exists into MAT
File “subject3455session6.mat” does not exist and create was not specified

Stacktrace:
[1] error(::String) at ./error.jl:33
[2] matopen(::String, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at /home/rakesh/.julia/packages/MAT/wBZA8/src/MAT.jl:44
[3] matopen(::String, ::String; compress::Bool) at /home/rakesh/.julia/packages/MAT/wBZA8/src/MAT.jl:88
[4] matopen at /home/rakesh/.julia/packages/MAT/wBZA8/src/MAT.jl:88 [inlined]
[5] #matopen#2 at /home/rakesh/.julia/packages/MAT/wBZA8/src/MAT.jl:97 [inlined]
[6] matopen(::String) at /home/rakesh/.julia/packages/MAT/wBZA8/src/MAT.jl:97
[7] top-level scope at In[1]:2nd_place_medal:

I think Julia’s current directory might be in the wrong location? Try running pwd() to see if that file path contains “subject3455session6.mat”.

Thanks for your response!

Sorry for the late reply. Your suggestion works but I am stuck in ploting the variables in .mat files. There are two different types of variables in the file , struct and cell arrays.

Could you help to know the syntax to plot these variables?

It’s very difficult to give a “one size fits all” answer, because structs and cell arrays are very general data types. If, for instance, each cell in the cell array contains a number, it would be appropriate to import it as or convert it to an Array{Float64}.

1 Like