Hi all,
I have this uncoupled linear system
\dot{x}_{1} = -x_{1}
\dot{x}_{2} = 2x_{2}
the system can be written in matrix form as
\dot{x} = Ax
with A = [-1 \ 0; 0 \ 2]
the general solution are:
x_{1} (t) = c_{1} e^{-t}
x_{2} (t) = c_{2} e^{2t}
or
x(t) = [e^{-t} \ 0; 0 \ e^{2t}]c
in the book they draw the phase portrait as below:
My question is how to draw such phase portrait?
Thanks.
For example like this with Makie: streamplot
1 Like
Is there any way to use CairoMakie in REPL and save the image as png, instead of using Jupyter Notebook / IJulia?
I need to add
using Meshes
but the codes do not work:
Function passed to streamplot must return Point2 or Point3
Stacktrace:
** [1] error(s::String)**
** @ Base ./error.jl:33**
** [2] streamplot_impl(CallType::Type, f::typeof(f), limits::Rect2D{Float64}, resolutionND::Tuple{Int64, Int64, Int64}, stepsize::Float64, maxsteps::Int64, dens::Float64)**
** @ Makie ~/.julia/packages/Makie/c5WJV/src/basic_recipes/streamplot.jl:112**
** [3] (::Makie.var"#611#616")(f::Function, limits::Rect2D{Float64}, resolution::Tuple{Int64, Int64, Int64}, stepsize::Float64, maxsteps::Int64, density::Float64)**
** @ Makie ~/.julia/packages/Makie/c5WJV/src/basic_recipes/streamplot.jl:167**
I am trying this code but can’t work to save the image as svg, which line do i miss?
using CairoMakie
struct FitzhughNagumo{T}
ϵ::T
s::T
γ::T
β::T
end
P = FitzhughNagumo(0.1, 0.0, 1.5, 0.8)
f(x, P::FitzhughNagumo) = Point2f(
(x[1]-x[2]-x[1]^3+P.s)/P.ϵ,
P.γ*x[1]-x[2] + P.β
)
f(x) = f(x, P)
streamplot(f, -1.5..1.5, -1.5..1.5, colormap = :magma)
save("/home/browni/LasthrimProjection/JupyterLab/CairoMakie/example.svg",fig)
This is the reason. It’s a simple fix, best share your code