# Rewriting a MATLAB library in Julia

**URL:** https://discourse.julialang.org/t/rewriting-a-matlab-library-in-julia/109515
**Category:** General Usage
**Tags:** matlab
**Created:** [January 31, 2024, 1:47pm UTC](https://discourse.julialang.org/t/rewriting-a-matlab-library-in-julia/109515 "2024-01-31T13:47:30Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [January 31, 2024, 4:36pm UTC](https://discourse.julialang.org/t/rewriting-a-matlab-library-in-julia/109515/6 "2024-01-31T16:36:33Z")

</div>

You don’t have to translate/map everything (just use, or read its mapping if you want to map):

> **[MatlabCompat.jl - MATLAB/Octave functions library for Julia](https://matlabcompat.github.io)**
>
> MatlabCompat.jl - MATLAB/Octave functions library for Julia

> **[Progressing from MATLAB to Julia: A Guide to Getting Started](https://www.datacamp.com/blog/progressing-from-matlab-to-julia)**
>
> Check out our guide for MATLAB programmers interested in transitioning to the Julia programming language. Find out everything you need to know to get started with Julia.

You can also just call to (or from) MATLAB:

> **[GitHub - JuliaInterop/MATLAB.jl: Calling MATLAB in Julia through MATLAB Engine](https://github.com/JuliaInterop/MATLAB.jl)**
>
> Calling MATLAB in Julia through MATLAB Engine. Contribute to JuliaInterop/MATLAB.jl development by creating an account on GitHub.

> [@\[ANN\] JuliaFromMATLAB.jl - Call Julia from MATLAB](https://discourse.julialang.org/t/ann-juliafrommatlab-jl-call-julia-from-matlab/66882):
>
> Inspired by this [recent discussion](https://discourse.julialang.org/t/calling-julia-from-matlab-the-smoothest-path-to-sneak-julia-into-a-company/64845) regarding the state of calling Julia from MATLAB, I have put together a package to try to resolve some of the issues faced by previous approaches: [JuliaFromMATLAB.jl](https://github.com/jondeuce/JuliaFromMATLAB.jl). Please scroll down to see the Quickstart guide, pasted here from the package’s README for convenience. In particular, I have chosen to avoid trying to keep up with the MATLAB Mex C/C++ interface. Instead, communication between MATLAB and Julia is performed by writing to temporary .mat files. This…

You CAN also call to Octave, the MATLAB clone language, then you have standard functions, lose out on toolboxes. But I couldn’t use the library for that at the time, and it’s still unchanged for 4 years now.

But I could call Python (then with PyCall, now would use PythonCall), and to Octave from it… Calliing Python in-process, not to Octave from it, it still works. And I had to disable OpenBLAS threading with an env var, do get around a bug.

This might help you migrate (I did in stages), or actually not migrate, just use MATLAB code.

There IS a MATLAB code translator available online, but it doesn’t handle all syntax, nor semantic differences:

> **[MATLAB to Julia translator | MATLAB to Julia converter](https://lakras.github.io/matlab-to-julia/)**
>
> Convenient online tool automatically translates MATLAB source code into Julia, so you can move on to the more interesting task of parallelizing your code.

---

_[View the full topic](https://discourse.julialang.org/t/rewriting-a-matlab-library-in-julia/109515)._
