# How to store Julia variables and matrices like mat files in MATLAB

**URL:** <https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571>\
**Category:** General Usage\
**Tags:** question, matlab\
**Created:** [October 11, 2021, 4:22pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571 "2021-10-11T16:22:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 11, 2021, 4:22pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571/1 "2021-10-11T16:22:06Z")

</div>

I just switched from Matlab to Julia. One thing I’m trying to figure out is how to store my variables in Julia like mat files in Matlab? For example, in Matlab I would do this:

save(‘test.mat’, ‘Var1’, ‘Var2’, ‘Var3’);

Would anyone please show me how to do this in Julia?

Thanks

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [October 11, 2021, 4:27pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571/2 "2021-10-11T16:27:47Z")

</div>

MAT.jl has what you need. Also, both Matlab and Julia can read and write  
HDF5 files (HDF5.jl).

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 11, 2021, 4:29pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571/3 "2021-10-11T16:29:23Z")

</div>

Many thanks! Glad to know the existence of such packages.

So Julia does not have its own proprietary way of storing variables on a hard disk?

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [October 11, 2021, 4:32pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571/4 "2021-10-11T16:32:36Z")

</div>

> [@leon](#):
>
> So Julia does not have its own proprietary way of storing variables on a hard disk?

Julia is open source, so the answer to that would be no.

There are plenty of packages that you could use though. JLD2.jl and HDF5.jl would offer similar capabilities to what you are used to in Matlab, I think.

> **[GitHub - JuliaIO/JLD2.jl: HDF5-compatible file format in pure Julia](https://github.com/JuliaIO/JLD2.jl)**
>
> HDF5-compatible file format in pure Julia. Contribute to JuliaIO/JLD2.jl development by creating an account on GitHub.

> **[GitHub - JuliaIO/HDF5.jl: Save and load data in the HDF5 file format from Julia](https://github.com/JuliaIO/HDF5.jl)**
>
> Save and load data in the HDF5 file format from Julia - GitHub - JuliaIO/HDF5.jl: Save and load data in the HDF5 file format from Julia

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [October 11, 2021, 4:36pm UTC](https://discourse.julialang.org/t/how-to-store-julia-variables-and-matrices-like-mat-files-in-matlab/69571/5 "2021-10-11T16:36:57Z")

</div>

Many thanks! I’ll check them out.
