@@ -302,74 +302,92 @@ end
302302@recipe function simresultplot (
303303 res:: SimResult{<:StateEstimator} ;
304304 plotŶ = true ,
305+ plotU = true ,
305306 plotD = true ,
306307 plotX = false ,
307308 plotX̂ = false
308309)
309310
310- estim = res. obj
311311 t = res. T_data
312- Ns = length (t)
313312
314313 ny = size (res. Y_data, 1 )
315314 nu = size (res. U_data, 1 )
316315 nd = size (res. D_data, 1 )
317316 nx = size (res. X_data, 1 )
318317 nx̂ = size (res. X̂_data, 1 )
319318
320- layout_mat = [(ny, 1 ) (nu, 1 )]
319+ layout_mat = [(ny, 1 )]
320+ plotU && (layout_mat = [layout_mat (nu, 1 )])
321321 (plotD && nd ≠ 0 ) && (layout_mat = [layout_mat (nd, 1 )])
322322 plotX && (layout_mat = [layout_mat (nx, 1 )])
323323 plotX̂ && (layout_mat = [layout_mat (nx̂, 1 )])
324324
325325 layout := layout_mat
326326
327+ xguide --> " Time (s)"
328+
327329 # --- outputs y ---
328330 subplot_base = 0
329331 for i in 1 : ny
330- @series begin plotX= true
331- xguide --> " Time (s)"
332+ @series begin
332333 yguide --> " \$ y_$i \$ "
333334 color --> 1
334335 subplot --> subplot_base + i
335336 label --> " \$\\ mathbf{y}\$ "
337+ legend --> false
336338 t, res. Y_data[i, :]
337339 end
338340 if plotŶ
339341 @series begin
340- xguide --> " Time (s)"
341342 yguide --> " \$ y_$i \$ "
342343 color --> 5
343344 subplot --> subplot_base + i
344345 linestyle --> :dashdot
345346 label --> " \$\\ mathbf{\\ hat{y}}\$ "
347+ legend --> true
346348 t, res. Ŷ_data[i, :]
347349 end
348350 end
349351 end
350352 subplot_base += ny
351353 # --- manipulated inputs u ---
352- for i in 1 : nu
353- @series begin
354- xguide --> " Time (s)"
355- yguide --> " \$ u_$i \$ "
356- color --> 1
357- subplot --> subplot_base + i
358- seriestype --> :steppost
359- label --> " \$\\ mathbf{u}\$ "
360- t, res. U_data[i, :]
354+ if plotU
355+ for i in 1 : nu
356+ @series begin
357+ yguide --> " \$ u_$i \$ "
358+ color --> 1
359+ subplot --> subplot_base + i
360+ seriestype --> :steppost
361+ label --> " \$\\ mathbf{u}\$ "
362+ legend --> false
363+ t, res. U_data[i, :]
364+ end
365+ end
366+ subplot_base += nu
367+ end
368+ # --- measured disturbances d ---
369+ if plotD
370+ for i in 1 : nd
371+ @series begin
372+ xguide --> " Time (s)"
373+ yguide --> " \$ d_$i \$ "
374+ color --> 1
375+ subplot --> subplot_base + i
376+ label --> " \$\\ mathbf{d}\$ "
377+ legend --> false
378+ t, res. D_data[i, :]
379+ end
361380 end
362381 end
363- subplot_base += nu
364382 # --- plant states x ---
365383 if plotX
366384 for i in 1 : nx
367385 @series begin
368- xguide --> " Time (s)"
369386 yguide --> " \$ x_$i \$ "
370387 color --> 1
371388 subplot --> subplot_base + i
372389 label --> " \$\\ mathbf{x}\$ "
390+ legend --> false
373391 t, res. X_data[i, :]
374392 end
375393 end
@@ -379,14 +397,14 @@ end
379397 if plotX̂
380398 for i in 1 : nx̂
381399 @series begin
382- xguide --> " Time (s)"
383400 yguide --> " \$\\ hat{x}_$i \$ "
384- color --> 1
401+ color --> 5
385402 subplot --> subplot_base + i
403+ linestyle --> :dashdot
386404 label --> " \$\\ mathbf{\\ hat{x}}\$ "
405+ legend --> false
387406 t, res. X̂_data[i, :]
388407 end
389408 end
390- subplot_base += nx̂
391409 end
392- end
410+ end
0 commit comments