# How to define an element inside a structure with type 3x3 Matrix{Float64}

**URL:** <https://discourse.julialang.org/t/how-to-define-an-element-inside-a-structure-with-type-3x3-matrix-float64/68357>\
**Category:** General Usage\
**Tags:** question, mutable-structure\
**Created:** [September 17, 2021, 11:07pm UTC](https://discourse.julialang.org/t/how-to-define-an-element-inside-a-structure-with-type-3x3-matrix-float64/68357 "2021-09-17T23:07:31Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 17, 2021, 11:29pm UTC](https://discourse.julialang.org/t/how-to-define-an-element-inside-a-structure-with-type-3x3-matrix-float64/68357/6 "2021-09-17T23:29:06Z")

</div>

> [@PetrKryslUCSD](#):
>
> I am doubtful one can have an initializer in the type. I would do

@PetrKryslUCSD  
It is possible from the below reference. However, it works well with vector, but not `Array{Float64, 2}`. Do you have any idea?

> [@Default value of \*some\* fields in a mutable struct](https://discourse.julialang.org/t/default-value-of-some-fields-in-a-mutable-struct/33408/4):
>
> This seems like a great use case for a macro. You might take inspiration from [https://github.com/mauro3/Parameters.jl](https://github.com/mauro3/Parameters.jl) which does something similar: julia\> using Parameters julia\> @with\_kw struct Foo x::Int32 = 1 y::Float64 end Foo julia\> Foo(y = 2) Foo x: Int32 1 …

```julia
julia> using Parameters, Base;
julia> Base.@kwdef mutable struct R
    Br::Vector{Float64} = [0,0,0]
    #Ls::Array{Float64, 2} = [0,0,0; 0,0,0; 0,0,0] 
end
julia> u = R()
R([0.0, 0.0, 0.0])

```

```julia
julia> Base.@kwdef mutable struct R
           Ls::Array{Float64, 2} = [0,0,0; 0,0,0; 0,0,0]
       end
ERROR: syntax: unexpected semicolon in array expression around util.jl:450
Stacktrace:
 [1] top-level scope
   @ REPL[6]:1

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-define-an-element-inside-a-structure-with-type-3x3-matrix-float64/68357)._
