Files
cmdla/10-04/plotQ.jl

11 lines
412 B
Julia
Raw Normal View History

2023-10-29 02:06:02 +01:00
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