@@ -73,9 +73,9 @@ using Plots
7373u = [0.5]
7474N = 35
7575res = sim!(model, N, u)
76- p1 = plot(res, plotu=false)
77- savefig("plot1_NonLinMPC.svg") # hide
78- display(p1 ) # hide
76+ p = plot(res, plotu=false)
77+ savefig(p, "plot1_NonLinMPC.svg") # hide
78+ display(p ) # hide
7979```
8080
8181![ plot1_NonLinMPC] ( plot1_NonLinMPC.svg )
@@ -105,9 +105,9 @@ p_plant = copy(p_model)
105105p_plant[3] = 1.25*p_model[3]
106106plant = setname!(NonLinModel(f, h, Ts, nu, nx, ny; p=p_plant); u=vu, x=vx, y=vy)
107107res = sim!(estim, N, [0.5], plant=plant, y_noise=[0.5])
108- p2 = plot(res, plotu=false, plotxwithx̂=true)
109- savefig("plot2_NonLinMPC.svg") # hide
110- display(p2 ) # hide
108+ p = plot(res, plotu=false, plotxwithx̂=true)
109+ savefig(p, "plot2_NonLinMPC.svg") # hide
110+ display(p ) # hide
111111```
112112
113113![ plot2_NonLinMPC] ( plot2_NonLinMPC.svg )
@@ -134,9 +134,9 @@ The option `Cwt=Inf` disables the slack variable `ϵ` for constraint softening.
134134using JuMP; unset_time_limit_sec(nmpc.optim) # hide
135135ry = [180.0]
136136res_ry = sim!(nmpc, N, ry, plant=plant, x_0=[0, 0], x̂_0=[0, 0, 0])
137- p3 = plot(res_ry)
138- savefig("plot3_NonLinMPC.svg") # hide
139- display(p3 ) # hide
137+ p = plot(res_ry)
138+ savefig(p, "plot3_NonLinMPC.svg") # hide
139+ display(p ) # hide
140140```
141141
142142![ plot3_NonLinMPC] ( plot3_NonLinMPC.svg )
@@ -147,9 +147,9 @@ satisfactory:
147147
148148``` @example man_nonlin
149149res_yd = sim!(nmpc, N, ry, plant=plant, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10])
150- p4 = plot(res_yd)
151- savefig("plot4_NonLinMPC.svg") # hide
152- display(p4 ) # hide
150+ p = plot(res_yd)
151+ savefig(p, "plot4_NonLinMPC.svg") # hide
152+ display(p ) # hide
153153```
154154
155155![ plot4_NonLinMPC] ( plot4_NonLinMPC.svg )
@@ -221,9 +221,9 @@ setpoint is similar:
221221unset_time_limit_sec(empc.optim) # hide
222222ry = [180.0, 0]
223223res2_ry = sim!(empc, N, ry, plant=plant2, x_0=[0, 0], x̂_0=[0, 0, 0])
224- p5 = plot(res2_ry, ploty=[1])
225- savefig("plot5_NonLinMPC.svg") # hide
226- display(p5 ) # hide
224+ p = plot(res2_ry, ploty=[1])
225+ savefig(p, "plot5_NonLinMPC.svg") # hide
226+ display(p ) # hide
227227```
228228
229229![ plot5_NonLinMPC] ( plot5_NonLinMPC.svg )
@@ -242,9 +242,9 @@ Also, for a 10° step disturbance:
242242
243243``` @example man_nonlin
244244res2_yd = sim!(empc, N, ry; plant=plant2, x_0=[π, 0], x̂_0=[π, 0, 0], y_step=[10, 0])
245- p6 = plot(res2_yd, ploty=[1])
246- savefig("plot6_NonLinMPC.svg") # hide
247- display(p6 ) # hide
245+ p = plot(res2_yd, ploty=[1])
246+ savefig(p, "plot6_NonLinMPC.svg") # hide
247+ display(p ) # hide
248248```
249249
250250![ plot6_NonLinMPC] ( plot6_NonLinMPC.svg )
@@ -330,9 +330,9 @@ function plotWithPower(res, Pmax)
330330 plot!(plt2, t, Pmax, label=raw"$P_\mathrm{max}$", linestyle=:dot, linewidth=1.5)
331331 return plot(plt1, plt2, layout=(2,1))
332332end
333- p7 = plotWithPower(res3_ry, Pmax)
334- savefig("plot7_NonLinMPC.svg") # hide
335- display(p7 ) # hide
333+ p = plotWithPower(res3_ry, Pmax)
334+ savefig(p, "plot7_NonLinMPC.svg") # hide
335+ display(p ) # hide
336336```
337337
338338![ plot7_NonLinMPC] ( plot7_NonLinMPC.svg )
@@ -366,9 +366,9 @@ The linear controller satisfactorily rejects the 10° step disturbance:
366366``` @example man_nonlin
367367ry = [180.0]
368368res_lin = sim!(mpc, N, ry; plant, x_0=[π, 0], y_step=[10])
369- p9 = plot(res_lin)
370- savefig("plot9_NonLinMPC.svg") # hide
371- display(p9 ) # hide
369+ p = plot(res_lin)
370+ savefig(p, "plot9_NonLinMPC.svg") # hide
371+ display(p ) # hide
372372```
373373
374374![ plot9_NonLinMPC] ( plot9_NonLinMPC.svg )
@@ -406,9 +406,9 @@ does slightly improve the rejection of the step disturbance:
406406
407407``` @example man_nonlin
408408res_lin2 = sim!(mpc2, N, ry; plant, x_0=[π, 0], y_step=[10])
409- p10 = plot(res_lin2)
410- savefig("plot10_NonLinMPC.svg") # hide
411- display(p10 ) # hide
409+ p = plot(res_lin2)
410+ savefig(p, "plot10_NonLinMPC.svg") # hide
411+ display(p ) # hide
412412```
413413
414414![ plot10_NonLinMPC] ( plot10_NonLinMPC.svg )
@@ -427,9 +427,9 @@ results:
427427
428428``` @example man_nonlin
429429res_ms = sim!(mpc_ms, N, ry; plant, x_0=[π, 0], y_step=[10])
430- plot!(p10 , res_ms)
431- savefig("plot10b_NonLinMPC.svg") # hide
432- display(p10 ) # hide
430+ plot!(p , res_ms)
431+ savefig(p, "plot10b_NonLinMPC.svg") # hide
432+ display(p ) # hide
433433```
434434
435435![ plot10b_NonLinMPC] ( plot10b_NonLinMPC.svg )
@@ -500,9 +500,9 @@ operating point. The [`SimResult`](@ref) object is for plotting purposes only. T
500500``` @example man_nonlin
501501x_0 = [0, 0]; x̂_0 = [0, 0, 0];
502502res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0)
503- p12 = plot(res_slin)
504- savefig("plot12_NonLinMPC.svg") # hide
505- display(p12 ) # hide
503+ p = plot(res_slin)
504+ savefig(p, "plot12_NonLinMPC.svg") # hide
505+ display(p ) # hide
506506```
507507
508508![ plot12_NonLinMPC] ( plot12_NonLinMPC.svg )
@@ -512,9 +512,9 @@ and the 10° step disturbance:
512512``` @example man_nonlin
513513x_0 = [π, 0]; x̂_0 = [π, 0, 0]; y_step = [10]
514514res_slin = sim_adapt!(mpc3, model, N, ry, plant, x_0, x̂_0, y_step)
515- p13 = plot(res_slin)
516- savefig("plot13_NonLinMPC.svg") # hide
517- display(p13 ) # hide
515+ p = plot(res_slin)
516+ savefig(p, "plot13_NonLinMPC.svg") # hide
517+ display(p ) # hide
518518```
519519
520520![ plot13_NonLinMPC] ( plot13_NonLinMPC.svg )
0 commit comments