Skip to content

Commit 4b778e1

Browse files
committed
plot SSE tracking error
1 parent 4d41ddc commit 4b778e1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

docs/src/examples/ilc.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ The next step is to implement the ILC scheme and run it:
134134
```@example ilc
135135
function ilc(Gc, Q, L)
136136
a = zero(r) # ILC adjustment signal starts at 0
137-
fig = plot(t, vec(r), sp=1, layout=(3,1), l=(:black, 3), lab="Ref")
137+
fig1 = plot(t, vec(r), sp=1, layout=(3,1), l=(:black, 3), lab="Ref")
138+
fig2 = plot(title="Sum of squared error", xlabel="Iteration", legend=false, titlefontsize=10, framestyle=:zerolines, ylims=(0, 7.1))
138139
for iter = 1:5
139140
ra = r .+ a
140141
res = lsim(Gc, ra, t) # Simulate system, replaced by an actual experiment if running on real process
@@ -143,10 +144,12 @@ function ilc(Gc, Q, L)
143144
Le = lsim_noncausal(L, e, t)
144145
a = lsim_zerophase(Q, a + Le, t) # Update ILC adjustment
145146
146-
plot!(res, plotu=true, sp=[1 2], title=["Output \$y(t)\$" "Adjusted reference \$r + a\$"], lab="Iter $iter", c=iter)
147-
plot!(e[:], sp=3, title="Tracking error \$e(t)\$", lab="err: $(round(sum(abs2, e), digits=2))", c=iter)
147+
err = sum(abs2, e)
148+
plot!(fig1, res, plotu=true, sp=[1 2], title=["Output \$y(t)\$" "Adjusted reference \$r + a\$"], lab="Iter $iter", c=iter)
149+
plot!(fig1, e[:], sp=3, title="Tracking error \$e(t)\$", lab="err: $(round(err, digits=2))", c=iter)
150+
scatter!(fig2, [iter], [err])
148151
end
149-
fig
152+
plot(fig1, fig2, layout=@layout([a{0.7w} b{0.3w}]))
150153
end
151154
ilc(Gc, Q, L)
152155
```

0 commit comments

Comments
 (0)