Hello, there!
I’m studying the spacing s between eigenvalues of 2\times2 matrices. My code is the following (some description lies in the comments):
using Distributions
using LinearAlgebra
d1 = Normal(0.0,1)
d2 = Normal(0.0,1/2)
N = 10 #size of the ensemble
for k in 1:N #loop that generates the N sets of eigenvalues
for i in 1:2 #generating the random gaussian matrix
for j in 1:2
if i == j B[i,j] = rand(d1)
end
end
end
B[1,2] = B[2,1] = rand(d2)
λ = eigvals(B) #calculating the eigenvalues
s[k] = abs(λ[1] - λ[2]) #calculating the spacement between them
end
I’m trying to storage the information about the spacement of the N matrices at the ensemble in the vector s, wich may have N components, but I receive the following error when I try to run:
MethodError: no method matching setindex!(::Float64, ::Float64, ::Int64)
Someone knows what is wrong?