|
52 | 52 | # ### Input reponse
|
53 | 53 |
|
54 | 54 | Y1, Time, Xsim = cnt.lsim(g_sample, Usim, Time)
|
55 |
| -plt.figure() |
| 55 | +plt.figure(0) |
56 | 56 | plt.plot(Time, Usim)
|
57 | 57 | plt.plot(Time, Y1)
|
58 | 58 | plt.xlabel("Time")
|
59 | 59 | plt.title("Time response y(t)=g*u(t)")
|
| 60 | +plt.legend(['u(t)', 'y(t)']) |
60 | 61 | plt.grid()
|
61 | 62 | plt.show()
|
62 | 63 |
|
63 | 64 | # ### Noise response
|
64 | 65 |
|
65 | 66 | Y2, Time, Xsim = cnt.lsim(h_sample, e_t, Time)
|
66 |
| -plt.figure() |
| 67 | +plt.figure(1) |
67 | 68 | plt.plot(Time, e_t)
|
68 | 69 | plt.plot(Time, Y2)
|
69 | 70 | plt.xlabel("Time")
|
70 | 71 | plt.title("Time response y(t)=h*e(t)")
|
| 72 | +plt.legend(['e(t)', 'y(t)']) |
71 | 73 | plt.grid()
|
72 | 74 | plt.show()
|
73 | 75 |
|
|
76 | 78 |
|
77 | 79 | Ytot = Y1 + Y2
|
78 | 80 | Utot = Usim + e_t
|
79 |
| -plt.figure() |
80 |
| -plt.plot(Time, Ytot) |
| 81 | +plt.figure(2) |
81 | 82 | plt.plot(Time, Utot)
|
| 83 | +plt.plot(Time, Ytot) |
82 | 84 | plt.xlabel("Time")
|
83 | 85 | plt.title("Time response y_t(t)=g*u(t) + h*e(t)")
|
| 86 | +plt.legend(['u(t) + e(t)', 'y_t(t)']) |
84 | 87 | plt.grid()
|
85 | 88 |
|
86 | 89 | # ## Perform system identification from collected data
|
|
94 | 97 | Y_hid1, Time, Xsim = cnt.lsim(Id_sys.H, e_t, Time)
|
95 | 98 | Y_idTot = Y_id1 + Y_hid1
|
96 | 99 |
|
97 |
| -plt.figure(0) |
| 100 | +plt.figure(3) |
98 | 101 | plt.plot(Time, Usim)
|
99 | 102 | plt.ylabel("Input PRBS")
|
100 | 103 | plt.xlabel("Time")
|
101 | 104 | plt.title("Input, validation data (Switch probability=0.08)")
|
102 | 105 | plt.grid()
|
103 | 106 | plt.show()
|
104 | 107 |
|
105 |
| -plt.figure(1) |
| 108 | +plt.figure(4) |
106 | 109 | plt.plot(Time, Ytot)
|
107 | 110 | plt.plot(Time, Y_idTot)
|
108 | 111 | plt.grid()
|
|
112 | 115 | plt.legend(['Original system', 'Identified system'])
|
113 | 116 | plt.show()
|
114 | 117 |
|
115 |
| -plt.figure(2) |
| 118 | +plt.figure(5) |
116 | 119 | plt.plot(Time, Y1)
|
117 | 120 | plt.plot(Time, Y_id1)
|
118 | 121 | plt.ylabel("y_out")
|
|
121 | 124 | plt.title("Gu (identification data)")
|
122 | 125 | plt.legend(['Original system', 'Identified system'])
|
123 | 126 |
|
124 |
| -plt.figure(3) |
| 127 | +plt.figure(6) |
125 | 128 | plt.plot(Time, Y2)
|
126 | 129 | plt.plot(Time, Y_hid1)
|
127 | 130 | plt.ylabel("y_err")
|
|
154 | 157 |
|
155 | 158 | # ## Check responses are almost equal
|
156 | 159 |
|
157 |
| -plt.figure(4) |
| 160 | +plt.figure(7) |
158 | 161 | plt.plot(Time, U_valid)
|
159 | 162 | plt.ylabel("Input PRBS")
|
160 | 163 | plt.xlabel("Time")
|
161 | 164 | plt.title("Input, validation data (Switch probability=0.07)")
|
162 | 165 | plt.grid()
|
163 | 166 | plt.show()
|
164 | 167 |
|
165 |
| -plt.figure(5) |
| 168 | +plt.figure(8) |
166 | 169 | plt.plot(Time, Ytotvalid)
|
167 | 170 | plt.plot(Time, Yidtotvalid)
|
168 | 171 | plt.xlabel("Time")
|
|
174 | 177 | rmse = np.round(np.sqrt(np.mean((Ytotvalid - Yidtotvalid) ** 2)), 2)
|
175 | 178 | plt.title("Validation: Gu+He | RMSE = {}".format(rmse))
|
176 | 179 |
|
177 |
| -plt.figure(6) |
| 180 | +plt.figure(9) |
178 | 181 | plt.plot(Time, Yvalid1)
|
179 | 182 | plt.plot(Time, Yidvalid1)
|
180 | 183 | plt.grid()
|
|
184 | 187 | plt.legend(['Original system', 'Identified system'])
|
185 | 188 | plt.show()
|
186 | 189 |
|
187 |
| -plt.figure(7) |
| 190 | +plt.figure(10) |
188 | 191 | plt.plot(Time, Yvalid2)
|
189 | 192 | plt.plot(Time, Yidvalid2)
|
190 | 193 | plt.grid()
|
|
194 | 197 | plt.legend(['Original system', 'Identified system'])
|
195 | 198 | plt.show()
|
196 | 199 |
|
197 |
| -plt.figure() |
| 200 | +plt.figure(11) |
198 | 201 | _ = cnt.bode([h_sample, Id_sys.H])
|
199 | 202 | plt.show()
|
200 | 203 |
|
201 |
| -plt.figure() |
| 204 | +plt.figure(12) |
202 | 205 | _ = cnt.bode([g_sample, Id_sys.G])
|
203 | 206 | plt.show()
|
0 commit comments