In [1]:
using PyPlot
In [52]:
function sym_ones(n,x)
if ! (x in 1:n)
error("x should be between 1 and n")
end
return hcat(zeros(n,x),eye(n,n-x)) + vcat(zeros(x,n),eye(n-x,n))
end
function matrixA(n)
return sym_ones(n, 1)
end
function matrixB(n)
out = zeros(n,n)
for i in 1:n-1
out += i*sym_ones(n, i)
end
return out
end
Out[52]:
In [53]:
imshow(matrixA(100), cmap="gray", interpolation="none")
Out[53]:
In [54]:
imshow(matrixB(100), cmap="gray", interpolation="none")
Out[54]:
In [74]:
for i in 2:16
plot(fill(i, i), eigvals(matrixA(i)), "o")
end
xlabel("n")
ylabel("Eigenwerte")
show()
In [99]:
ev = eigvecs(matrixA(8))
for i in 1:8
plot(1:8, ev[:,i], "-x", label="Eigenvektor $i")
end
ax = gca()
ax[:set_position]([0.06,0.06,0.8,0.91])
xlabel("Basisvektor")
ylabel("Wert")
legend(loc="center left", bbox_to_anchor=(1, 0.5))
show()
In [ ]: