juliaplots.jl

Ploting a function in Julia


I would like to plot following mathematical modell of the p-V-diagramm

enter image description here

However, when I try to plot the function I get a different plot.

T0 = 492
V0 = 275
Tmax = 25
Vmax = 75
vals = []

for t in range(1,stop=2*π,length=30)
    push!(vals, (T0 + Tmax*sin(t))/(V0-Vmax*cos(t)))
end

plot(vals, legend=nothing)

enter image description here

I am not sure if I am using plots right.


Solution

  • reference:

    julia> T0 = 492
    
    julia> V0 = 275
    
    julia> Tmax = 25
    
    julia> Vmax = 75
    
    julia> using Plots
    
    julia> V(t) = V0-Vmax*cos(t)
    V (generic function with 1 method)
    
    julia> P(t) = (T0 + Tmax*sin(t))/V(t)
    P (generic function with 1 method)
    
    julia> plot(V, P, 0:0.1:2pi)
    

    enter image description here