System Identification using MATLAB and Simulink

in StemSocial3 years ago (edited)

1. Introduction

We explores system identification in modeling state space equations and transfer function of the system. System identification builds system models using the measurements of the system’s input and output signal. The input data should be a chirp signal and has a symmetric frequency sweep. In this paper, we used system identification tool in MATLAB and Simulink to validate the transfer function of the system.

nvsazn3cfzpt7tlisy1z
Figure 1: Electrical circuit of the given system

The system consist of a voltage input, u(t), resistors, R1, R2 and R3, inductors, L1 and L2, and capacitors, C1 and C2. The output y(t) is equal to the voltage across the resistor, R2. The values of each elements are R1, R2, R3 = 10 Ω, 1 , L2 = 0.5 H and C1, C2 = 50 mF. The system has a transfer function equal to

image.png

2. System Representation in Simulink

st9fpuj6wgik0cdppvlt
Figure 2: Block diagram representation in Simulink

We represent the transfer function in equation (1) as a block diagram in Simulink, shown in Figure 2. The block diagram representation of the system consist of an input, a scope, a multiplexer, two summing point, three integrator, and ten gains. In MATLAB, we generate a chirp signal with a frequency between 0 to 10 Hz by using the script:

%system identification
t = 0:0.0001:30;
t1 = [0:0.0001:60]';
y = chirp(t,0,60,10);

x = wrev(y(1,1:end-1));
xa = [y x]';
x1 = [t1 xa];
plot(t1,xa);

dej5x9pvmcqezdotpcvi
(a) Input (from workspace) block settings

vipyuml3owrgwj68rvz5
(b) Scope general settings

yfcyonqjanh4texm7tok
(c) Saving simulation data as ScopeData

Figure 3: Setting the input and scope block in Simulink

We run the script and yield a chirp signal shown in Figure 4a. Next, we set up the sampling time of the simulation to 1/10,000 of a second for the input block and the scope in Figure 2. We also save the simulation data from the scope as ScopeData in MATLAB workspace. These settings are shown in Figure 3. Then, we run the simulation and generate the output signal in Figure 4b.

qzyqxv7bdwpccvahrtdj
(a) Input signal with symmetric frequency sweep

gv2i7zjekndzvoznlt9t
(b) Input and output signal in the scope

Figure 4: System’s Input and Output Signal

3. System Identification

From the simulation, we acquire and save simulation data in MATLAB workspace as ScopeData. The file contains the time, input and output values from the simulation. Figure 5 shows ScopeData in MATLAB workspace and the data in ScopeData file.

t88jpzucvlw9nkqwlklg
(a) ScopeData in MATLAB workspace

wz8kmtefnyfeybrnkbg5
(b) Datasets in ScopeData

Figure 5: Data from the system simulation in Simulink

From the ScopeData, we extract the input and output data from the array. We run the script:

input = ScopeData(:,2);
output = ScopeData(:,3);

to correctly assigned the input and output values to a specific variable. Next, we run

ident

in windows console to access the system identification tool in MATLAB. The system identification window is shown in Figure 6a.

vk1kt4zierohuxkd8747
(a) System Identification tool in MATLAB

ihkec4wteo2iyeenmnss
(b) Importing dataset

rgeilbrkr2pneseh6r6g
(c) Simulation data imported in system identification window.

Figure 6: Accessing system identification tool and importing data to it

Next, we import the simulation data as data in the system identification windows. We also set the starting and sampling time to 0 and 1/10000 respectively, as shown in Figure 6b. To check the data, click the time plot and it displays Figure 7a.

pdrmn2fjpuolkwybf1iv
(a) time plot for data

rztwygrvtohbqelp7oox
(b) time plot for data1

p8mydrwfgy292pcf9ovy
(c) time plot for data2

Figure 7: Input and output signal used for system identification

Then, we extract a working and validation data from data by setting up a different range for both data samples. We set the the time frame of the working data to 0 ≤ t ≤ 30 by accessing the drop down menu in preprocess and click on select range. We name the working data as data1. The setting for data1 is shown in Figure 8a. For the validation data, we set it to 30 ≤ t ≤ 60 and name it as data2. The setting for data1 and data2 is shown in Figure 8a and 8b respectively. After importing the data to system identification window, drag data1 to working data and data2 to validation data, as shown in Figure 8c. The time plot for data1 and data2 are shown in Figure 7b and 7c respectively.

nk5o64pfzft40mdt4hyp
(a) Setting up data1

kawghjtrrgdrfglshzoj
(b) Setting up data2

pwlexakxmyxgo13aylxm
(c) Assigning the working and validation data

Figure 8: Preprocessing data for system identification

Lastly, we create the system model by clicking on the drop down menu in estimate and select state space model. In the state space model window as shown in Figure 9, set the model according to the settings in Figure 9 and click estimate. The system estimates the model order and rank based on its singular values, as shown in Figure 10. The system returns 10 model order for the simulation data. We choose the recommended model order and click insert to import the state space model into the system identification window.

yzfa8nzuga5e8xawxh1y


f8gthl0rdnwjo0087uej
Figure 9: Setting up the state space model

symfqpmjusvhn2ppcwfw
Figure 10: Estimated model order

by3xsqba2quvalsvxdw1
Figure 11: State space model imported to system identification window

The state space model, ss1, is now in the system identification as shown in Figure 13. We check the model output, transient response, frequency response, and zeros and poles for the estimated state space model.

tlkfucx21uedlecpamdf
(a) Model Output

qbb5nidyrhlk9so45por
(b) Transient Response

vmhnavh5je5ilpclb3kf
(c) Frequency Response

mkw8gdg5m54ns0dnj5ij
(d) Zeros and Poles

Figure 12: State Space System Response

In Figure 12a, the state space model scores a 100% curve fitting between the measured and simulated model output. This suggest that the model correctly estimates the model from the simulation data. Other responses of the state space model are plotted in Figure 12. After checking the system output and responses, we imported the state space model to the MATLAB workspace by dragging it to workspace. Figure 13 shows ss1 is in MATLAB workspace.

We run ss1 in windows console to generate the state space model of the system. The state model is


image.png

rzy6aunycfap8ff2sowg
Figure 13: State space model imported in workspace.

4. Validating the Transfer Function

In this section, we validate the transfer function in equation (1) to the transfer function generated by system identification using MATLAB and Simulink. We run

tf(ss1)

in windows console and get the transfer function from system identification as


image.png

The transfer function from system identification is not in the same order as to the transfer function in equation (1) but numerically both transfer function yield to same response. Simplifying equation(1), we get

image.png

The first order model of the transfer function in equation (2) is equal to the transfer function from system identification. Thus, we validate that derived transfer function was correct.

5. Conclusion

In this paper, we are able to validate the transfer function in equation (1) and perform system identification using MATLAB and Simulink. We observed that system identification models system accurately from a set of input and output signal. In this paper, system identification methodology was able to derived the transfer function of the system from the simulation data in Simulink. It is a powerful tool in solving for the system models of systems without known characteristics and internal parameters. Also, it has a high accuracy in generating the estimated models.

6. References

[1] Norman S. Nise. Control Systems Engineering (7th. ed.). 2015. John Wiley & Sons, Inc., USA.

[2] DiStefano, J. J., Stubberud, A. R., & Williams, I. J. (2013). Schaum's outline of theory and problems of feedback and control systems. New York: McGraw-Hill.

[3] Bishop, Robert H., and Richard C. Dorf. "Modern control systems." (2017).

[4] Schijndel, Jos. (2011). The Use of System Identification Tools in MatLab for Transfer Functions. Personality and Individual Differences

[5] Ljung, Lennart. (2011). System Identification Toolbox for use with MATLAB. 21.

(Note: All images in the text is created by the author (@juecoree) except those with separate citation.)

If your interested in the modelling of the system transfer function in the text, read the previous post on:
1. State Space Model and System Transfer Functions

Posted with STEMGeeks

Posted with STEMGeeks

Sort: