# Access the contents of a mat file

**URL:** <https://discourse.julialang.org/t/access-the-contents-of-a-mat-file/61977>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [May 28, 2021, 7:40am UTC](https://discourse.julialang.org/t/access-the-contents-of-a-mat-file/61977 "2021-05-28T07:40:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deepa/32/23385_2.png) [@Deepa](https://discourse.julialang.org/u/Deepa)\
**Post date:** [May 28, 2021, 7:40am UTC](https://discourse.julialang.org/t/access-the-contents-of-a-mat-file/61977/1 "2021-05-28T07:40:50Z")

</div>

Hi All,

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

```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?

---

<div class="post-metadata">

**Author:** ![RGerzaguet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rgerzaguet/32/45492_2.png) [@RGerzaguet](https://discourse.julialang.org/u/RGerzaguet)\
**Post date:** [May 28, 2021, 7:47am UTC](https://discourse.julialang.org/t/access-the-contents-of-a-mat-file/61977/2 "2021-05-28T07:47:04Z")

</div>

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

```
