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 :slight_smile:

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: image

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 :wink:

1 Like

It is a homework task

Go for it on your own. Whenever you are stuck or strange errors come up you don’t understand, check back with us and we will help, if we just see that you are trying.

1 Like

Hint: It seems by “lattice” the problem means “2d array of values” representing a spatial grid.