I wanted to write matrix for the total coin angular momentum with the following code

mvalues = -j:1:j

cardinality = length(mvalues)

# Jminus is zero except for directly above the diagonal

# There is an implicit \hbar & square root

Jminus = zeros(cardinality)

for i=2:cardinality

m = mvalues[i]

Jminus[i-1, i] = sqrt(j*(j+1)-m*(m-1))

end

After compiling, I am getting the following error

BoundsError: attempt to access 9-element Vector{Float64} at index [1, 2]

I am new to Julia, therefore any suggestion would be very helpful.