# Julia for MATLAB users club

**URL:** <https://discourse.julialang.org/t/julia-for-matlab-users-club/12872>\
**Category:** General Usage\
**Tags:** proposal, matlab\
**Created:** [August 4, 2018, 12:40am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872 "2018-08-04T00:40:24Z")\
**Posts on this page:** 13\
**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:** [August 4, 2018, 12:40am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/1 "2018-08-04T00:40:24Z")

</div>

… or maybe: posse? armada? crew? gang? task force? K-Pop group? 😛

Continuing the discussion from [Why `eye` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/64):

^ I proposed some sort of SIG for MATLAB users who like me are coming from a MATLAB background and either migrating code to Julia or considering whether to do so:

> [@Why \`eye\` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/64):
>
> Ok so maybe rather than just my specific suggestions of contributing to the Wikibook and working on a `MatlabToJulia.jl` (or modernizing `MatlabCompat.jl` ) is anyone interested in forming some sort of MATLAB/Julia users SIG which can do these sorts of things (including others’ probably better ideas than mine) in a coordinated way? This could just be a sub-forum here on Discourse (and, if people insist, a Slack channel, but ugh, Slack 🙂 ).
> 
> I think individually we probably are very busy and have little time but collectively we can do a lot to turn some of the kinds of discussion we have on threads like these into some concrete solutions that build on the (1.0) core language.

… and was encouraged (thanks!) to start a new thread:

> [@Why \`eye\` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/70):
>
> > [@Why \`eye\` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/68):
> >
> > @StefanKarpinski could we get perhaps a subcategory of Development?
> 
> I’m not Stefan, but I’m also a moderator here — why don’t you start with a new thread and if there’s sufficient interest/traffic we can expand it out to a subcategory. Really, though, I think this would be best coordinated around a specific repository (like MatlabCompat) and discussion within issues there.

Tagging those who liked the post and/or expressed interest in that thread:  
@mbauman, @rsmaior, @fruno, @Ronis_BR @Seif_Shebl

The first concrete suggestions have been:

1. Flesh out the [Wikibook](https://en.wikibooks.org/wiki/Julia_for_MATLAB_Users) that I recently started (don’t get too excited, it’s just embryonic at this point)
2. “Revive” [MatlabCompat.jl](https://github.com/MatlabCompat/MatlabCompat.jl) in some sense (IMO before hacking on it we should step back and think about things like different use cases, avoiding too many dependencies, etc.)

As I expressed in the earlier thread, I also think that coming from any other language there will be similar questions, so I hope that if folks band together similarly for, e.g. Python users learning Julia, that we can combine forces here.

---

<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:** [August 4, 2018, 6:11am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/2 "2018-08-04T06:11:57Z")

</div>

Just my 2c worth: I found that the array indexing being superficially similar in Matlab and in Julia helped with porting low-level code from Matlab to Julia. On the other hand, I found that making a decisive and clean break from Matlab by totally rejecting its software design principles is the only way to get a nice Julia code. By that I mean for instance taking full advantage of multiple dispatch, modifiable arguments (especially arrays), and getting rid of the vectorized-code-is-the-only-way thinking.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 4, 2018, 6:18am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/3 "2018-08-04T06:18:03Z")

</div>

Exactly. I started out creating some vectorized routines along these lines:

> **[GitHub - ChrisRackauckas/VectorizedRoutines.jl: Familiar vectorized routines...](https://github.com/ChrisRackauckas/VectorizedRoutines.jl)**
>
> Familiar vectorized routines from R/Python/MATLAB, plus some more. - GitHub - ChrisRackauckas/VectorizedRoutines.jl: Familiar vectorized routines from R/Python/MATLAB, plus some more.

But eventually you just start engineering better software and drop it. But I’m an ex-MATLABer and will likely help in places.

This thread really doesn’t belong in development though.

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [August 4, 2018, 12:12pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/4 "2018-08-04T12:12:13Z")

</div>

I don’t know we’re you got the idea that we want to write vectorized (awfully memory wasteful) code and ignore multiple dispatch.

I also don’t know for others but for me I just want to be able to use familiar function names (linspace, strtok, flipdim, cumsum, repmat, etc…) without having to loose time digging in the docs how to do the same thing with Julia functions/constructs.

---

<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:** [August 4, 2018, 12:17pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/5 "2018-08-04T12:17:48Z")

</div>

I certainly wouldn’t presume to suggest that you would write bad code. It was purely a reflection on the value of maintaining some semblance of the Julia code to Matlab code, including potentially having the “same” code run on both platforms.

I personally believe that making a clean break and sticking to Julia conventions will make my code easier to read for anyone familiar with Julia (but not with Matlab). And that is much more valuable to me than having to learn a few new names.

---

<div class="post-metadata">

**Author:** ![cortner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cortner/32/204_2.png) [@cortner](https://discourse.julialang.org/u/cortner)\
**Post date:** [August 5, 2018, 4:40pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/6 "2018-08-05T16:40:33Z")

</div>

I agree but: Did you feel the same when you first switched? Is this still true if just quickly want to hack together a crude test that is not intended to be read / reused?

Virtually everybody on this thread is (relatively speaking) a power user. Please don’t forget about beginners or just people who need to write a few simple codes to publish a paper but couldn’t care less about how elegant and consistent the design of the language is.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 5, 2018, 8:18pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/7 "2018-08-05T20:18:25Z")

</div>

There are a few different audiences of Matlab natives, and each group needs to be directed towards different sets of resources to get up to speed in Julia.

1. True beginners: they’ve played with a few scripts in Matlab, but they haven’t been around long enough to pick up bad habits. Send 'em towards a guide with lots of in-depth examples aimed at novice programmers, e.g. Chris’s fantastic [intro](http://ucidatascienceinitiative.github.io/IntroToJulia/) or the [QuantEcon course](https://lectures.quantecon.org/jl/index_learning_julia.html).
2. Intermediates: they know enough to be dangerous. They have expectations about how functions fit together, how to structure code to make it fast, and how to use and abuse the syntax. They need a syntax cheat sheet, e.g. [this](https://juliadocs.github.io/Julia-Cheat-Sheet/) or [this](https://cheatsheets.quantecon.org) (which they’ll be able to find on their own), plus full explanations of ‘surprising’ things about Julia, including [noteworthy differences](https://docs.julialang.org/en/latest/manual/noteworthy-differences/#Noteworthy-differences-from-MATLAB-1), [performance tips](https://docs.julialang.org/en/latest/manual/performance-tips/), and [gotchas](http://www.stochasticlifestyle.com/7-julia-gotchas-handle/).  
It’d also be worthwhile to collect all the Matlab-conversion Discourse threads in one place (maybe with a tag?), since there are few better ways to learn than by example.
3. Experts/application builders: they’ll start with the same set of resources as intermediates, but they don’t need much handholding and’ll just start RTFMing of their own accord.

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 5, 2018, 8:25pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/8 "2018-08-05T20:25:26Z")

</div>

Additionally, I think there’s a lot of value in having a meta-package that re-exports everything needed to get a Matlab or SciPy-like experience. `from scipy import *` is a terrible software engineering practice, but that doesn’t make it any less useful for exploratory work. I went through the Matlab docs and came up with the rough list below; I don’t think everything there necessarily belongs in `Batteries.jl`, but it’s a start. I’m really not looking forward to resolving the swarm of namespace conflicts this’ll spit out.

# Mathematics

## Elementary math

- Primes.jl
- Combinatorics.jl
- Polynomials.jl
- DSP.jl
- SpecialFunctions.jl
- CoordinateTransformations.jl
- SpecialMatrices.jl
- MatrixDepot.jl
- Base.MathConstants

## Linear algebra

- LinearAlgebra (stdlib)

## Random numbers

- Random (stdlib)

## Interpolation

- Interpolations.jl
- Dierckx.jl
- ScatteredInterpolation.jl

## Optimization

- Optim.jl
- LsqFit.jl

## Numerical integration and differential equations

- DifferentialEquations.jl
- QuadGK.jl
- ApproxFun.jl

## Fourier analysis and filtering

- FFTW.jl
- DSP.jl

## Sparse matrices

- SparseArrays (stdlib)
- IterativeSolvers.jl

## Graphs

- LightGraphs.jl
- GraphPlot.jl

## Computational geometry

- GeometricalPredicates.jl
- VoronoiDelaunay.jl

# Graphics

- Plots.jl
- Luxor.jl
- Images.jl
- ImageView.jl

# Data import and analysis

## Data import and export

### Text files

- DelimitedFiles (stdlib)
- CSV.jl
- CSVFiles.jl

### Spreadsheets

- Too many options! Need a performance shootout.
- ExcelReaders.jl for raw arrays
- ExcelFiles.jl for use with DataFrames
- Taro.jl
- XLSX.jl

### Images

- FileIO.jl
- ImageMagick.jl

### Scientific data

- NetCDF.jl
- HDF5.jl
- FITSIO.jl

### Audio and video

- FileIO.jl
- VideoIO.jl
- Still missing a convenient, portable video-writing interface

### Low-level IO: files, streams, TCP/IP

- In base! [https://docs.julialang.org/en/stable/manual/networking-and-streams/](https://docs.julialang.org/en/stable/manual/networking-and-streams/)

### Web access

- HTTP.jl
- FTPClient.jl
- SMTPClient.jl
- JSON.jl

### Serial port devices

- SerialPorts.jl

## Preprocessing data & descriptive statistics

- Missing values: in base! [https://docs.julialang.org/en/latest/manual/missing/](https://docs.julialang.org/en/latest/manual/missing/)
- DataFrames.jl
- DataFramesMeta.jl
- StatsBase.jl
- Queryverse.jl
- Statistics (stdlib)
- Distributions.jl

---

<div class="post-metadata">

**Author:** ![shorty66](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shorty66/32/3254_2.png) [@shorty66](https://discourse.julialang.org/u/shorty66)\
**Post date:** [August 6, 2018, 7:37am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/9 "2018-08-06T07:37:21Z")

</div>

> [@stillyslalom](#):
>
> I’m really not looking forward to resolving the swarm of namespace conflicts this’ll spit out.

Me neither, but it might help to resolve these conflicts. That way the `matlab-users-club` could give back to the julia community.

---

<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:** [August 6, 2018, 9:20am UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/10 "2018-08-06T09:20:25Z")

</div>

> [@stillyslalom](#):
>
> I think there’s a lot of value in having a meta-package that re-exports everything needed to get a Matlab or SciPy-like experience.

Creating such a package should be conceptually easy, just really tedious. If a few users (or just one person) truly finds this valuable, then they should just do it.

---

<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:** [August 6, 2018, 12:32pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/11 "2018-08-06T12:32:06Z")

</div>

> [@stillyslalom](#):
>
> There are a few different audiences of Matlab natives, and each group needs to be directed towards different sets of resources to get up to speed in Julia.

Indeed, and along with those experience based audiences I’ll add that I think there are people who might be in any of the groups you identify and also are trying to determine:

1. **If Julia is suitable for porting a specific existing piece of Matlab code to Julia.** These people will want to know to what extent whatever Matlab functionality they are using has an existing equivalent in Julia. Depending on their familiarity with Julia they may need an almost drop-in replacement, or if that isn’t available and they are more comfortable in Julia they may just want to plan to spend some time developing the Julia equivalent.
2. **Whether Julia can be used in a certain domain where otherwise Matlab would be used.** Often this will be in a business context. For instance, an aerospace controls engineering team might wonder if Julia could be used for design and analysis of the controller for their next product, where they would otherwise default to Matlab (plus toolboxes). Decisions such as these will be a function of a number of things: the degree to which Julia already has the needed equivalent functionality, how stable/complete that functionality is, the projected costs of the team members learning Julia, costs for team members’ time to implement missing functionality, and so on.

In both of these cases the decision involves (or should involve) a determination of whether an investment of resources today will be worthwhile over time based on some prediction of how popular a language Julia will become. Clearly there is a snowball effect with language popularity–despite Matlab’s many warts because it was widely used in certain areas it attracted more users, and this in turn attracted more, etc. Hopefully Julia’s broader applicability (and availability, being open source) as a language will accelerate this process, much in the way that happened with Python.

I’ll add another audience: For those who know neither language yet, there are those making a decision of whether to learn Julia or Matlab. Julia should have a huge advantage here given its free availability, though from many university students’ perspectives, at least, Matlab appears to be effectively free or nearly so due to site licensing and/or educational discounts. Maybe this suggests that for adoption in the longer term it is worthwhile for the community (and Julia Computing) to focus some resources on helping younger people learn Julia.

> [@stillyslalom](#):
>
> Additionally, I think there’s a lot of value in having a meta-package that re-exports everything needed to get a Matlab or SciPy-like experience. `from scipy import *` is a terrible software engineering practice, but that doesn’t make it any less useful for exploratory work.

I like what this idea is getting at, and there may be other ways to accomplish the same goal. For instance, especially for exploratory work, what if there was a hotkey in the REPL (or maybe OhMyREPL) that when hit following a Matlab keyword/function name would pop up suggestions for Julia equivalents? Or as I’ve suggested before as part of a package of Matlab ‘aliases’ there was an option where something like deprecation warnings could be enabled so that at runtime based on the specific data types (and even values) being used, more appropriate Julia-native suggestions could be made?

Actually I wonder too if the notional `Batteries.jl` (maybe it should be called `MatlabBatteries.jl`) could be written such that it doesn’t directly have any dependencies but defines all the keywords that are available in a number of distinct packages. Further the help system could be leveraged to encourage users of this package to use native Julia equivalents with something similar to the deprecation warnings that are printed in 0.7 when methods like `eye` are called. So the main package could be designed that you could do something like:

```plaintext
julia>using MatlabBatteries

julia>eye(3)
ERROR: To use a Matlab drop-in replacement for eye, add a using statement:
using MatlabFundamentals

julia>using MatlabFundamentals

julia>?eye

A drop-in for the MATLAB function eye is available:

  julia> using MatlabFundamentals: eye; twotimesidentity = 2 * eye(3)
  3×3 Array{Float64,2}:
   2.0 0.0 0.0
   0.0 2.0 0.0
   0.0 0.0 2.0

For a direct native Julia replacement, consider `Matrix(1.0I, m, m)` or 
`Matrix{Float64}(I, m, m)`. If `Float64` element type is not necessary, 
consider the shorter `Matrix(I, m, m)` (with default `eltype(I)` `Bool`).

```

> [@stillyslalom](#):
>
> I went through the Matlab docs and came up with the rough list below; I don’t think everything there necessarily belongs in `Batteries.jl` , but it’s a start. I’m really not looking forward to resolving the swarm of namespace conflicts this’ll spit out.

Awesome! I’m definitely going to borrow from this list to help populate the Wikibook, thanks! This also reminds me that I need to add an Acknowledgments section. 🙂

---

<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:** [August 7, 2018, 4:06pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/12 "2018-08-07T16:06:53Z")

</div>

> [@Why \`eye\` has been deprecated?](https://discourse.julialang.org/t/why-eye-has-been-deprecated/12824/94):
>
> [https://github.com/JuliaLang/julia/pull/28456/commits/3b84ab46d4ec1aab70ee537e0d1a704e0df84b10](https://github.com/JuliaLang/julia/pull/28456/commits/3b84ab46d4ec1aab70ee537e0d1a704e0df84b10).  
> 👋 there was a really witty comment in ‘stdlib/LinearAlgebra/src/deprecated.jl’ (gone now too):
> 
> ```julia
> - ## goodbeye, eye!
> - export eye
> - function eye(m::Integer)
> - depwarn(string( ...
> - ...
> 
> ```

I think we have the first function name for `MatlabPuns.jl`:

```julia
export goodbeye
function goodbeye(m::Integer)
    return Matrix{Float64}(I, m, m)
end
function goodbeye(::Type{T}, m::Integer) where T
    return Matrix{T}(I, m, m)
end
function goodbeye(m::Integer, n::Integer)
    return Matrix{Float64}(I, m, n)
end
function goodbeye(::Type{T}, m::Integer, n::Integer) where T
    return Matrix{T}(I, m, n)
end
function goodbeye(A::AbstractMatrix{T}) where T
    return Matrix(one(T)I, size(A))
end
function goodbeye(::Type{Diagonal{T}}, n::Int) where T
    return Diagonal{T}(I, n)
end

```

Hmm, what others would work?

- `linspace` → `linspacedout`
- `diagm` → `diagmeh`
- `flipdim` → `flippingoutdim`
- `eig` → `whyohwhyg`
- `sum(A, n)` → `dimsum(A, n)`

… actually that last one kind of makes sense… 😛

---

<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:** [August 9, 2018, 2:55pm UTC](https://discourse.julialang.org/t/julia-for-matlab-users-club/12872/13 "2018-08-09T14:55:18Z")

</div>

> [@airpmb](#):
>
> I think we have the first function name for `MatlabPuns.jl` :

> **[GitHub - pbouffard/MatlabPuns.jl: Deprecations? Schmeckprecations!](https://github.com/pbouffard/MatlabPuns.jl)**
>
> Deprecations? Schmeckprecations! Contribute to pbouffard/MatlabPuns.jl development by creating an account on GitHub.
