# How do i make a square lattice of (2n+1) x (2n+1)?

I need to define a square lattice of size (2n+1) x (2n+1) and assign each cell as zero. Could anyone help me out on how to do this?

What have you tried so far?

7 Likes

Define a â€ślatticeâ€ť.

1 Like

Perhaps:

``````julia> n=2
2

julia> zeros(Float64,2n+1,2n+1)
5Ă—5 Matrix{Float64}:
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
0.0  0.0  0.0  0.0  0.0
``````

if lattice=matrix

1 Like

Hi, I havenâ€™t got anywhere with it atm. I am really stuck with it.

What is the context of your problem? Where does it come from and what are you going to do with the â€ślatticeâ€ť?

This is what I was given:

Is this a homework question or an exam or something? We wouldnâ€™t want to take away the learning experience for you (but we do want to help).

1 Like

I would use the contents of the lessons/classes, which I perhaps have missed, by accident. My class mates may have some scripts or there has been some book suggested, which, after reading, would lead me more or less straight forward to the solution of this offering. But of course, thatâ€™s just me

1 Like