Skip to content

Commit 972391e

Browse files
committed
Changing some plotting mistakes
1 parent 029a075 commit 972391e

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

Examples/ARMAX.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,24 @@
5252
# ### Input reponse
5353

5454
Y1, Time, Xsim = cnt.lsim(g_sample, Usim, Time)
55-
plt.figure()
55+
plt.figure(0)
5656
plt.plot(Time, Usim)
5757
plt.plot(Time, Y1)
5858
plt.xlabel("Time")
5959
plt.title("Time response y(t)=g*u(t)")
60+
plt.legend(['u(t)', 'y(t)'])
6061
plt.grid()
6162
plt.show()
6263

6364
# ### Noise response
6465

6566
Y2, Time, Xsim = cnt.lsim(h_sample, e_t, Time)
66-
plt.figure()
67+
plt.figure(1)
6768
plt.plot(Time, e_t)
6869
plt.plot(Time, Y2)
6970
plt.xlabel("Time")
7071
plt.title("Time response y(t)=h*e(t)")
72+
plt.legend(['e(t)', 'y(t)'])
7173
plt.grid()
7274
plt.show()
7375

@@ -76,11 +78,12 @@
7678

7779
Ytot = Y1 + Y2
7880
Utot = Usim + e_t
79-
plt.figure()
80-
plt.plot(Time, Ytot)
81+
plt.figure(2)
8182
plt.plot(Time, Utot)
83+
plt.plot(Time, Ytot)
8284
plt.xlabel("Time")
8385
plt.title("Time response y_t(t)=g*u(t) + h*e(t)")
86+
plt.legend(['u(t) + e(t)', 'y_t(t)'])
8487
plt.grid()
8588

8689
# ## Perform system identification from collected data
@@ -94,15 +97,15 @@
9497
Y_hid1, Time, Xsim = cnt.lsim(Id_sys.H, e_t, Time)
9598
Y_idTot = Y_id1 + Y_hid1
9699

97-
plt.figure(0)
100+
plt.figure(3)
98101
plt.plot(Time, Usim)
99102
plt.ylabel("Input PRBS")
100103
plt.xlabel("Time")
101104
plt.title("Input, validation data (Switch probability=0.08)")
102105
plt.grid()
103106
plt.show()
104107

105-
plt.figure(1)
108+
plt.figure(4)
106109
plt.plot(Time, Ytot)
107110
plt.plot(Time, Y_idTot)
108111
plt.grid()
@@ -112,7 +115,7 @@
112115
plt.legend(['Original system', 'Identified system'])
113116
plt.show()
114117

115-
plt.figure(2)
118+
plt.figure(5)
116119
plt.plot(Time, Y1)
117120
plt.plot(Time, Y_id1)
118121
plt.ylabel("y_out")
@@ -121,7 +124,7 @@
121124
plt.title("Gu (identification data)")
122125
plt.legend(['Original system', 'Identified system'])
123126

124-
plt.figure(3)
127+
plt.figure(6)
125128
plt.plot(Time, Y2)
126129
plt.plot(Time, Y_hid1)
127130
plt.ylabel("y_err")
@@ -154,15 +157,15 @@
154157

155158
# ## Check responses are almost equal
156159

157-
plt.figure(4)
160+
plt.figure(7)
158161
plt.plot(Time, U_valid)
159162
plt.ylabel("Input PRBS")
160163
plt.xlabel("Time")
161164
plt.title("Input, validation data (Switch probability=0.07)")
162165
plt.grid()
163166
plt.show()
164167

165-
plt.figure(5)
168+
plt.figure(8)
166169
plt.plot(Time, Ytotvalid)
167170
plt.plot(Time, Yidtotvalid)
168171
plt.xlabel("Time")
@@ -174,7 +177,7 @@
174177
rmse = np.round(np.sqrt(np.mean((Ytotvalid - Yidtotvalid) ** 2)), 2)
175178
plt.title("Validation: Gu+He | RMSE = {}".format(rmse))
176179

177-
plt.figure(6)
180+
plt.figure(9)
178181
plt.plot(Time, Yvalid1)
179182
plt.plot(Time, Yidvalid1)
180183
plt.grid()
@@ -184,7 +187,7 @@
184187
plt.legend(['Original system', 'Identified system'])
185188
plt.show()
186189

187-
plt.figure(7)
190+
plt.figure(10)
188191
plt.plot(Time, Yvalid2)
189192
plt.plot(Time, Yidvalid2)
190193
plt.grid()
@@ -194,10 +197,10 @@
194197
plt.legend(['Original system', 'Identified system'])
195198
plt.show()
196199

197-
plt.figure()
200+
plt.figure(11)
198201
_ = cnt.bode([h_sample, Id_sys.H])
199202
plt.show()
200203

201-
plt.figure()
204+
plt.figure(12)
202205
_ = cnt.bode([g_sample, Id_sys.G])
203206
plt.show()

Examples/ARX_MIMO.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def lsim(sys, U = 0.0, T = None, X0 = 0.0):
202202
plt.xlabel("Time")
203203
plt.grid()
204204

205-
plt.figure(3)
205+
plt.figure(1)
206206
plt.subplot(3, 1, 1)
207207
plt.plot(Time, Ytot1)
208208
plt.plot(Time, Yout_id[:, 0])

Examples/SS.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
import matplotlib.pyplot as plt
6060

6161
plt.close("all")
62-
plt.figure(1)
62+
plt.figure(0)
6363
plt.plot(Time, y_tot[0])
6464
plt.plot(Time, yid[0])
6565
plt.ylabel("y_tot")
@@ -68,7 +68,7 @@
6868
plt.title("Ytot")
6969
plt.legend(['Original system', 'Identified system, ' + method])
7070

71-
plt.figure(2)
71+
plt.figure(1)
7272
plt.plot(Time, U[0])
7373
plt.ylabel("input")
7474
plt.grid()

0 commit comments

Comments
 (0)