# MAT.jl or HDF5.jl?

**URL:** https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075
**Category:** New to Julia
**Tags:** matlab
**Created:** [November 14, 2017, 7:06pm UTC](https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075 "2017-11-14T19:06:15Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)
#### Post date: [November 14, 2017, 7:06pm UTC](https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075/1 "2017-11-14T19:06:15Z")

</div>

It’s not obvious which of these one should reach for first. I imagine the answer may be “it depends” but supposing you just have a `.mat` file drop in your lap what do you try first?

---

<div class="post-metadata">

### Author: ![airpmb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/airpmb/32/7826_2.png) [@airpmb](https://discourse.julialang.org/u/airpmb)
#### Post date: [November 14, 2017, 7:42pm UTC](https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075/2 "2017-11-14T19:42:27Z")

</div>

Answering myself (sort of): `MAT.jl` worked on the file I’m working with currently, FWIW. Ideally for my current use case I’d like to have similar behavior to MATLAB’s `load` command, i.e. create/update variables in the workspace. I found that something like the following seems to do that:

```julia
using MAT
data = matread(fname)
for k in keys(data)
    eval(parse("$k = data[\"$k\"]"))
end

```

I expect there’s a smarter way to do this so it can be put in a function, is safer, etc. Anyhow I’m guessing this is a common use case and someone has a better way.

Thanks!

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [November 15, 2017, 7:35am UTC](https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075/3 "2017-11-15T07:35:06Z")

</div>

FWIW, I would ingest the data in whatever format it is provided in, and from that point on use  
[https://github.com/simonster/JLD2.jl](https://github.com/simonster/JLD2.jl)

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [November 15, 2017, 3:21pm UTC](https://discourse.julialang.org/t/mat-jl-or-hdf5-jl/7075/4 "2017-11-15T15:21:55Z")

</div>

If I understand correctly, the OP wants to load a `.mat` file: she is not asking for saving data.
