Skip to content

Commit ade2117

Browse files
committed
@layout macro is not necessary
1 parent 9f95d97 commit ade2117

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

example/juMPC.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test_mpc(linModel4 , mpc)
156156

157157

158158
res = sim(mpc, mpc.Hp+10, x0=zeros(mpc.estim.model.nx))
159-
ps = plot(res, plotD=false, plotŶminŶmax=false, plotUminUmax=false)
159+
ps = plot(res, plotD=false, plotŶ=true, plotŶminŶmax=false, plotUminUmax=false)
160160
display(ps)
161161

162162
res2 = sim(uscKalmanFilter1, mpc.Hp+10)

src/plot_sim.jl

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,12 @@ end
317317
nx = size(res.X_data, 1)
318318
nx̂ = size(res.X̂_data, 1)
319319

320-
# TODO: @layout macro with dynamic expressions
321-
# layout_mat = :([(ny,1) (nu,1)])
322-
#if plotD && nd ≠ 0
323-
# (layout_mat = [layout_mat (nd,1)])
324-
#end
325-
#plotX && (layout_mat = [layout_mat (nx,1)])
326-
#plotX̂ && (layout_mat = [layout_mat (nx̂,1)])
320+
layout_mat = [(ny, 1) (nu, 1)]
321+
(plotD && nd 0) && (layout_mat = [layout_mat (nd, 1)])
322+
plotX && (layout_mat = [layout_mat (nx, 1)])
323+
plotX̂ && (layout_mat = [layout_mat (nx̂, 1)])
327324

328-
#println(layout_mat)
329-
330-
layout := @layout (nd 0 && plotD) ? [(ny,1) (nu,1) (nd, 1)] : [(ny,1) (nu,1)]
325+
layout := layout_mat
331326

332327
# --- outputs y ---
333328
subplot_base = 0
@@ -366,7 +361,6 @@ end
366361
end
367362
end
368363
subplot_base += nu
369-
#=
370364
# --- plant states x ---
371365
if plotX
372366
for i in 1:nx
@@ -379,6 +373,20 @@ end
379373
t, res.X_data[i, :]
380374
end
381375
end
376+
subplot_base += nx
377+
end
378+
# --- estimated states x̂ ---
379+
if plotX̂
380+
for i in 1:nx̂
381+
@series begin
382+
xguide --> "Time (s)"
383+
yguide --> "\$\\hat{x}_$i\$"
384+
color --> 1
385+
subplot --> subplot_base + i
386+
label --> "\$\\mathbf{\\hat{x}}\$"
387+
t, res.X̂_data[i, :]
388+
end
389+
end
390+
subplot_base += nx̂
382391
end
383-
=#
384392
end

0 commit comments

Comments
 (0)