# Does Julia have an equivalent to MATLAB's linsolve?

**URL:** <https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124>\
**Category:** New to Julia\
**Created:** [April 12, 2021, 4:42pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124 "2021-04-12T16:42:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nash/32/14482_2.png) [@Nash](https://discourse.julialang.org/u/Nash)\
**Post date:** [April 12, 2021, 4:42pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124/1 "2021-04-12T16:42:46Z")

</div>

Does Julia have the equivalent of MATLAB’s linsolve?

[Link](https://www.mathworks.com/help/symbolic/linsolve.html) to MATLAB’s function

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 12, 2021, 4:47pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124/2 "2021-04-12T16:47:05Z")

</div>

```julia
julia> A = [ 2 1 1
            -1 1 -1
            1 2 3 ]
3×3 Matrix{Int64}:
  2 1 1
 -1 1 -1
  1 2 3

julia> B = [2, 3, -10]
3-element Vector{Int64}:
   2
   3
 -10

julia> X = A \ B
3-element Vector{Float64}:
  3.0
  1.0
 -5.0

```

(I think Matlab has the same notation, doesn’t it?)

---

<div class="post-metadata">

**Author:** ![zdenek\_hurak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdenek_hurak/32/53118_2.png) [@zdenek\_hurak](https://discourse.julialang.org/u/zdenek_hurak)\
**Post date:** [April 12, 2021, 4:52pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124/3 "2021-04-12T16:52:39Z")

</div>

Well, through Matlab’s [linsolve](https://www.mathworks.com/help/matlab/ref/linsolve.html) function you can also specify some additional parameters (`X = linsolve(A,B,opts)`). That is perhaps where the question is directed.

---

<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:** [April 12, 2021, 4:55pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124/4 "2021-04-12T16:55:09Z")

</div>

> [@zdenek\_hurak](#):
>
> Well, through Matlab’s [linsolve](https://www.mathworks.com/help/matlab/ref/linsolve.html) function you can also specify some additional parameters ( `X = linsolve(A,B,opts)` ).

But Julia will do it for you! If your system is sparse or has other special features, it is likely that the backsolve (`\`) method has a specialized method which will be invoked to take advantage of that.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 12, 2021, 5:47pm UTC](https://discourse.julialang.org/t/does-julia-have-an-equivalent-to-matlabs-linsolve/59124/5 "2021-04-12T17:47:02Z")

</div>

> [@zdenek\_hurak](#):
>
> Well, through Matlab’s [linsolve](https://www.mathworks.com/help/matlab/ref/linsolve.html) function you can also specify some additional parameters ( `X = linsolve(A,B,opts)` ). That is perhaps where the question is directed.

In Julia, the analogue of `linsolve`’s options to specify the matrix type are done using either special matrix types, e.g. `UpperTriangular(A) \ B`, or through factorization objects, e.g. `cholesky(A) \ B` (if A is SPD), and in general the factorization functions may accept additional parameters.
