# Replacing normal arrays with static arrays

**URL:** <https://discourse.julialang.org/t/replacing-normal-arrays-with-static-arrays/28230>\
**Category:** New to Julia\
**Tags:** linearalgebra\
**Created:** [August 31, 2019, 6:07am UTC](https://discourse.julialang.org/t/replacing-normal-arrays-with-static-arrays/28230 "2019-08-31T06:07:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [August 31, 2019, 6:22am UTC](https://discourse.julialang.org/t/replacing-normal-arrays-with-static-arrays/28230/2 "2019-08-31T06:22:46Z")

</div>

`SMatrix` is immutable, but you can use `MMatrix` like this:

```julia
julia> function euler(φ, θ, ψ)
           R = MMatrix{3,3,Float64}(undef)
           cosφ = cos(φ); cosψ = cos(ψ); cosθ = cos(θ)
           sinφ = sin(φ); sinψ = sin(ψ); sinθ = sin(θ)

           R[1,1] = cosφ*cosθ*cosψ - sinφ*sinψ
           R[1,2] = sinφ*cosθ*cosψ + cosφ*sinψ
           R[1,3] = -sinθ*cosψ

           R[2,1] = -cosφ*cosθ*sinψ - sinφ*cosψ
           R[2,2] = -sinφ*cosθ*sinψ + cosφ*cosψ
           R[2,3] = sinθ*sinψ

           R[3,1] = cosφ*sinθ
           R[3,2] = sinφ*sinθ
           R[3,3] = cosθ

           return SMatrix(R)
       end

```

---

_[View the full topic](https://discourse.julialang.org/t/replacing-normal-arrays-with-static-arrays/28230)._
