11 lines
412 B
Julia
11 lines
412 B
Julia
|
|
using LinearAlgebra
|
||
|
|
using Plots
|
||
|
|
|
||
|
|
function plotQ(Q::Matrix, q::Vector, xyrange::Tuple{Tuple{Number, Number}, Tuple{Number, Number}})::Plots.Plot
|
||
|
|
f(x, y) = dot((1/2) * hcat(x, y) * Q, vcat(x, y)) + dot(q', vcat(x, y))
|
||
|
|
xrange = LinRange(xyrange[1][1], xyrange[2][1], 200)
|
||
|
|
yrange = LinRange(xyrange[1][2], xyrange[2][2], 200)
|
||
|
|
z = @. f(xrange', yrange)
|
||
|
|
plt = contour(xrange, yrange, z)
|
||
|
|
plt
|
||
|
|
end
|