filtering and system identification - project report

29
Delft Center for Systems and Control Identification of a Flexible Beam Setup SC4040 - Filtering and Identification Roxana Bucsa - 4330110 Radu Florea - 4330358 Remy Kabel - 4132165 SC4040 Filtering and Identification

Upload: raduf517

Post on 27-Nov-2015

61 views

Category:

Documents


7 download

TRANSCRIPT

Page 1: Filtering and System Identification - Project Report

Delft Center for Systems and Control

Identification of a Flexible BeamSetupSC4040 - Filtering and Identification

Roxana Bucsa - 4330110Radu Florea - 4330358Remy Kabel - 4132165

SC4040

Filte

ringandIdentifi

catio

n

Page 2: Filtering and System Identification - Project Report
Page 3: Filtering and System Identification - Project Report

Table of Contents

1 Introduction 11-1 Description of the system . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-2 Description of the assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Data Pre-processing 32-1 Data analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32-2 Spectrum analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52-3 Detrending, Data Compression and Order Estimation . . . . . . . . . . . . . . . 6

3 Model Estimation, Validation and Optimization 73-1 Hankel Matrix Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73-2 Estimation of States-Space Matrices . . . . . . . . . . . . . . . . . . . . . . . . 83-3 Model Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83-4 Auto-Correlation Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83-5 Cross-Correlation Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93-6 Cross-Validation Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113-7 Variance Accounted For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113-8 Model Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4 Conclusion 15

A Identification Matlab Script 17

i

Page 4: Filtering and System Identification - Project Report

ii Table of Contents

ii

Page 5: Filtering and System Identification - Project Report

Chapter 1

Introduction

As a finalizing project for the TU Delft course SC4040 Filtering and System Identification,the task has been assigned to us to identify, validate, and optimize several data sets for acertain experimental model. This puts the knowledge gathered throughout the course to thetest in a practical setting.

1-1 Description of the system

Figure 1-1: The experimental setup of the flexible beam

The experimental setup considers a flexible beam structure as depicted in Figure 1-1. Sixpiezos are bonded to the beam, three of which are visible in the photograph and three ofwhich are located at the rear of the beam. These piezos can either be used to develop a strainwhen a voltage is applied to them (causing the beam to bend) or they can detect a strain by

1

Page 6: Filtering and System Identification - Project Report

2 Introduction

emitting a voltage when the beam is bent. In the setup used here, piezos 1 and 3 are usedas actuators, whereas piezos 2, 4, 5 and 6 are used as sensors. For this system the maximumvoltage that can be supplied is 250 Volt before the actuators saturate. The constraint on thesensor outputs is 10 Volt before the electronic amplifiers saturate.

1-2 Description of the assignment

As a starting point, seven different data sets are given with inputs and corresponding outputsfor all piezos. The channels (rows) in the data sets are defined as:

• 1 - time (seconds)

• 2-5 - measurements from piezos 2, 4, 5 and 6 (Volts)

• 6-7 - signals sent to piezos 1 and 3 (Volts)

• 8 - sample counter (not used)

The task at hand is to identify the real life system. First, however, all data sets must bepre-processed to find any unsuitable sets. In the following chapters we will follow the methodof identification as described in figure 4.1 in [1, p.65].

2

Page 7: Filtering and System Identification - Project Report

Chapter 2

Data Pre-processing

As noted previously, before starting the identification of the data gathered in the experiment,the datasets must first be analyzed to discard any unusable sets. As such, this chapterdescribes how the available data sets are processed in order to decide upon the discarding ofthe sets.

2-1 Data analysis

Whereas one might like to jump in to start doing any such processing operations, it is a goodidea to first do a general analysis of the collected data and try to observe any particularitieswithin it. To this end, the obtained input-output data has been plotted; to better study it.The obtained plots are presented in Figure 2-1 and Figure 2-2.

It can immediately be observed that, for dataset 3 (Figure 2-2), the output electronic ampli-fiers have been saturated. This renders the whole data set unusable due to the fact that it isnot possible to extract any knowledge on the system’s behavior beyond the saturation point.This is information which might be crucial in obtaining an accurate estimate of the system.As such, dataset 3 will be dismissed for the rest of the identification process. Another way ofanalyzing the datasets is by looking at the provided .mat data file. From this we can obtainthe actual number of samples that the different data sets contain, as well as the samplingperiod that was used to obtain the data. Using the notation: ts,i for the time sample of dataset i, and Ns,i for the number of samples of data set i, with i = 1, ..., 7, the following valuesare observed:{

ts,1 = 0.001sNs,1 = 50000

{ts,2 = 0.001sNs,2 = 50000

{ts,3 = 0.001sNs,3 = 20000

{ts,4 = 0.001sNs,4 = 20000

{ts,5 = 0.001sNs,5 = 750

{ts,6 = 0.00005sNs,6 = 10000

{ts,7 = 0.001sNs,7 = 10000

3

Page 8: Filtering and System Identification - Project Report

4 Data Pre-processing

0 5 10 15 20 25 30 35 40−100

0

100

0 5 10 15 20 25 30 35 40−100

0

100

0 5 10 15 20 25 30 35 40−200

0

200

0 5 10 15 20 25 30 35 40−200

0

200

0 5 10 15−500

0

500

0 5 10 15−500

0

500

0 5 10 15−10

0

10

Am

plit

ude

[V

]

0 5 10 15−10

0

10

0 0.1 0.2 0.3 0.4 0.5−100

0

100

0 0.1 0.2 0.3 0.4 0.5−100

0

100

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4−100

0

100

0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4−100

0

100

0 1 2 3 4 5 6 7 8−100

0

100

Time [s]0 1 2 3 4 5 6 7 8

−100

0

100

Figure 2-1: Input signals of the data sets.Piezo 1 (left) and piezo 3 (right).

From top to bottom are datasets 1 to 7.

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 20 40−10

0

10

0 10 20−10

0

10

0 10 20−10

0

10

0 10 20−10

0

10

0 10 20−10

0

10

0 10 20−1

0

1

Am

plit

ud

e [

V]

0 10 20−1

0

1

0 10 20−1

0

1

0 10 20−1

0

1

0 0.2 0.4−5

0

5

0 0.2 0.4−5

0

5

0 0.2 0.4−5

0

5

0 0.2 0.4−5

0

5

0 0.2 0.4−10

0

10

0 0.2 0.4−10

0

10

0 0.2 0.4−10

0

10

0 0.2 0.4−10

0

10

0 5 10−5

0

5

0 5 10−5

0

5

Time [s]

0 5 10−5

0

5

0 5 10−5

0

5

Figure 2-2: Output signals of the data sets.From left to right: piezo 2, piezo 4, piezo 5, and piezo 6

From top to bottom are datasets 1 to 7.

4

Page 9: Filtering and System Identification - Project Report

2-2 Spectrum analysis 5

Through looking at the values for the running time of the experimental analyses and thenumber of samples used for this timespan, we can exclude two datasets: dataset 5 and 6.Similar findings can be gathered from the data presented in Figure 2-2. Despite dataset6 having a large number of samples, the sample frequency used is very large resulting inthe shortest running time of the experiment, namely 0.5 seconds. Similarly, dataset 5 alsoonly encompasses a running time of 0.75 seconds. Basically, such running times of gatheringexperimental data are too short to analyze the slower dynamics of the system. As such, partof the information of the experiment is lost upon using either of these datasets.

2-2 Spectrum analysis

In order to reduce the influence of noise in certain areas of the spectrum, we pre-filter theremaining four signals. Before pre-filtering the data, it should be noted that the useful signaland the disturbance can be separated because the signal has signal power mainly in thelow frequencies, while the noise contains mostly high frequencies. This may be observedby plotting the spectrum of the signal with the help of the MATLAB function pwelch. Thisreturns the power spectral density estimate of the discrete-time signal vector using the Welch’saveraged, modified periodogram method. The results have been plotted in Figure 2-3.

0 0.5 1−70

−60

−50

−40

−30

−20

−10

0

10

20

30

Po

we

r/fr

eq

ue

ncy (

dB

/ra

d/s

am

ple

)

0 0.5 1−70

−60

−50

−40

−30

−20

−10

0

10

20

30

Normalized Frequency ( × π rad/sample)0 0.5 1

−70

−60

−50

−40

−30

−20

−10

0

10

20

30

0 0.5 1−70

−60

−50

−40

−30

−20

−10

0

10

20

30

Figure 2-3: Power spectrum of the output signals.From left to right: dataset 1, dataset 2, dataset 4, and dataset 7.

Based on the spectrum in Figure 2-3 and on output signals from Figure 2-2, a rather lowpower and low output amplitude can be observed for data set 4. This gives an indication thatthis data set can be highly sensible to noise, thus it is not as reliant as the rest, therefore itwill be eliminated from the data sets considered for the identification process.

5

Page 10: Filtering and System Identification - Project Report

6 Data Pre-processing

0 10 20 3010

1

102

103

104

S−value0 10 20 30

101

102

103

104

S−value0 5 10 15 20

101

102

103

104

S−value

Figure 2-4: Singular valuesFrom left to right: dataset 1, dataset 2, dataset 4, and dataset 7)

2-3 Detrending, Data Compression and Order Estimation

Before starting the subspace identification of the model, first, some more preliminary actionshave to be taken. To start, the signals will be detrended. This pre-filtering is done using theMATLAB function detrend and removes unknown offsets and/or linear trends from signals.

Furthermore, in order to later be able to do the cross-validation procedure (presented inChapter 3), the measured data is split into two parts: an identification part (representing thefirst 2/3 of the data set) and a validation part (which is the remaining 1/3 of the data).

As a method of subspace identification, we are looking to implement the PO-MOESP usingthe supplied MATLAB toolbox. For this, several steps have to be taken. Firstly, the orderof the system should be estimated. Consecutively, the A and C matrices may be estimatedand finally, the B and D matrices of the system subspace may be estimated. In this chapterwe will restrict ourselves to the necessary preliminary actions. The actual estimation of thestate-space of the system will be discussed in Chapter 3.

In pursuance of the order of the system, an estimate may be drawn from the singular values.To obtain the singular values, we use the available "ord" function - dordpo in the case ofPO-MOESP - in order to compress the data and to generate a model order estimate. Forthis, we only need to specify the block-size parameter s, which should be considered largerthan the expected order of the system, s=30. The obtained vector S contains the singularvalues and will be presented shortly. Additionally, a compressed matrix R is obtained whichwill further be used to estimate the system matrices A and C in the next chapter.

The singular values are plotted by the use of the MATLAB function semilogy. Based on theresults plotted in Figure 2-4, we can choose to estimate a model of order 9-16.

6

Page 11: Filtering and System Identification - Project Report

Chapter 3

Model Estimation, Validation andOptimization

In the previous chapter, the datasets have been analyzed and pre-processed. Remaining arethe three datasets (data set 1, data set 2 and data set 7) which are usable and, supposedly,grant enough information to construct an accurate model of the entire system. As such, thischapter will entail the estimation and validation of the model. Upon the completion of this,the gathered results may be optimized.

3-1 Hankel Matrix Test

In order to verify the richness property of the input, which is mathematically called persistencyof excitation, the Hankel matrices specific to the inputs of every data set need to be verified.This actually means that for the available data sets,the order of every Hankel matrix is checkedto have full rank s, where s = 3n and n is the desired system order. The Hankel matrix hasthe form [2]:

U0,s,N =

u (0) u (1) · · · u (N − 1)u (1) u (2) · · · u (N)...

... . . . ...u (s− 1) u (s) · · · u (N + s− 2)

(3-1)

It is computed using the MATLAB function hankel. Running the Hankel matrix test for adesired model of order 9 (n = 9, s = 27) and order 16 (n = 16, s = 48), we obtain the ranksfor the Hankel matrices, presented in Table 3-1.

From the gathered results it is clear that the inputs used in data set 2 are not persistentlyexciting of order s, when s ε [27, 48] (i.e. n ε [9, 16]). Therefore, it is safe to conclude that dataset 2 is of no use in estimating a system of the desired order.

7

Page 12: Filtering and System Identification - Project Report

8 Model Estimation, Validation and Optimization

Table 3-1: Hankel matrix rank for different desired model orders

Data set Hankel matrix rank for input 1 Hankel matrix rank for input 2n = 9 (s = 27) n = 16 (s = 48) n = 9 (s = 27) n = 16 (s = 48)

1 27 48 27 482 14 14 14 147 27 48 27 48

3-2 Estimation of States-Space Matrices

As described before in paragraph 2-3, after estimating the order of the system, the a modelof the system may be created by constructing the state-space matrices. First, the system ma-trices A, C as well as the Kalman gain K are estimated using the toolbox function dmodpo.These estimates are of the system in innovation form. In order to establish this, the infor-mation previously obtained, namely the data matrix R, is used. Consecutively, the toolboxfunction dac2bd is used to estimate B and D.

3-3 Model Validation

Considering that an estimated model (Ae,Be,Ce,De) is available, the next step is to validatethis model on the basis of a more detailed inspection. In order to do this, we use the testsavailable within the class of residual tests, namely the auto-correlation and cross-correlationtests. These validation methods are applied to innovation models in which an optimal modelmeans that the variance of the one-step ahead predictor error is minimal. For a parameterestimate ε of ε, the one-step-ahead prediction error ε

(k, θ) can be estimated via the Kalman-

filter equations [2, p.387]. If the system under consideration can be represented by a modelin the innovation form, the prediction-error sequence for ε equal to the global optimum,calculated using data from an open-loop experiment, should be the following:

• The sequence ε(k, θ) is a zero-mean white-noise sequence.

• The sequence ε(k, θ) is independent of the input sequence u(k).

In order to obtain the vector ε(k, θ) we use the toolbox function dltisim. For this, we have

to provide the innovation state-space model previously obtained and we obtain the residualvector, as the difference between the actually measured output y(k) and the innovation modeloutput y

(k, θ).

3-4 Auto-Correlation Test

After obtaining the residual vector ε(k, θ), we have to check the whiteness of the residual

vector. We can do this by computing its auto-correlation function. To do this, we use theMATLAB Signal Proceesing Toolbox function xcorr. The output of this function will give usthe cross-correlation between two signals, and the cross correlation of ε

(k, θ) and ε

(k, θ) equals

8

Page 13: Filtering and System Identification - Project Report

3-5 Cross-Correlation Test 9

−3000 −2000 −1000 0 1000 2000 3000−2

0

2x 10

4

−3000 −2000 −1000 0 1000 2000 3000−1

0

1x 10

4

−3000 −2000 −1000 0 1000 2000 3000−2

0

2x 10

4

−3000 −2000 −1000 0 1000 2000 3000−1

0

1x 10

4

Lag

Figure 3-1: The auto-correlation function for dataset 1.From top to bottom: outputs 1 to 4.

an auto-correlation. The auto-correlation is defined as a signal of length 2N+1, correspondingto the auto-correlation from lag -MAXLAG up to and including lag +MAXLAG. The resultshave been plotted in Figure 3-1 for dataset 1 and in Figure 3-2, for dataset 7.

The decision to first estimate an order 9 model has been taken in order to be able to evaluatethe auto-correlation and cross-correlation functions specific to the estimated models fromdataset 1 and dataset 7. This will help in deciding if both the datasets are suited for systemidentification.

3-5 Cross-Correlation Test

As previously mentioned, the cross-correlation test is a residual test that can be used oninnovation state-space models. The role of this test is to check the second property of theresidual vector, as specified in the previous section: the residual vector has to be independentof the input signal u(k). For this, we are going to use the same residual vector computedbefore. The only difference is the fact that we now compute the cross-correlation betweenthe residual and the input signal using the same MATLAB function xcorr. We use the samevalue for the lag as before. The results have been plotted in Figure 3-3 for dataset 1 and inFigure ?? for dataset 7. Based on these, it can clearly be seen that the residual sequenceε (k, θ), of the model estimated using dataset 7, is not a zero-mean white-noise sequence andthe cross-correlation between it and the input is higher than the one of the residual vectorobtained from the estimated model using dataset 1. Thus, dataset 7 does not give out a goodmodel estimate, therefore it will be discarded.

9

Page 14: Filtering and System Identification - Project Report

10 Model Estimation, Validation and Optimization

−3000 −2000 −1000 0 1000 2000 3000−50

0

50

−3000 −2000 −1000 0 1000 2000 3000−100

0

100

−3000 −2000 −1000 0 1000 2000 3000−100

0

100

−3000 −2000 −1000 0 1000 2000 3000−100

0

100

Lag

Figure 3-2: The auto-correlation function for dataset 7.From top to bottom: outputs 1 to 4.

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

−5000 0 5000−2

−1

0

1

2x 10

5

Lag

Figure 3-3: The cross-correlation function for dataset 1.From top to bottom: outputs 1 to 4.

10

Page 15: Filtering and System Identification - Project Report

3-6 Cross-Validation Test 11

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

−5000 0 5000−1000

−500

0

500

1000

Lag

Figure 3-4: The cross-correlation function for dataset 7.From top to bottom: outputs 1 to 4.

3-6 Cross-Validation Test

It may happen that the we cannot know for sure that the model adequetly describes thesystem dynamics. This may happen due to overfiitting, which actually means that the modelcomplexity or the number of model parameters has become so large with respect to the lengthof the data sequence that the predicted output matches very accurately the identification data.

In order to prevent this from happening, the measured data is split in two parts as touchedupon in section 2-3: an identification part and a validation part. This means that the identi-fication part (we consider the first 2/3 of all samples), after which we can apply the validationtests on the second part (the remaining 1/3 of all samples) of the measured data.

This procedure has been applied to all datasets before starting any other procedure. Thepresented auto and cross-correlation plots are obtained using the validation part of the givendata.

3-7 Variance Accounted For

The variance accounted for (VAF) is defined as a scaled variant of the cost function JN

(θ)

and it is defined as (formula page 4.4 page 78 companion).

This can be easily computed in MATLAB by using the toolbox function vaf for all thecomponents of the output signal. It requires the measured output y(k) (only the validationpart) and the predicted output y

(k). The values obtained are between 0% and 100%; the

higher the value of the VAF, the lower the prediction error and the better the model obtainedthrough identification.

In order to decide the order of the most accurate model, the system has been estimated foreight different orders (n = 9...16), after which the VAF, for each one of these models, has

11

Page 16: Filtering and System Identification - Project Report

12 Model Estimation, Validation and Optimization

Table 3-2: VAF for different estimated model orders

Model order VAF of Output 1 VAF of Output 2 VAF of Output 3 VAF of Output 49 90.4186 91.4660 93.0888 93.708610 90.3580 91.5305 93.2522 93.821911 90.3500 91.5012 93.2521 93.825912 90.2027 91.6933 93.5027 94.058513 90.0076 91.7611 93.5970 94.172414 89.8875 91.7555 93.6187 94.189415 89.7378 91.7518 93.5852 94.175816 89.5581 91.5508 93.6436 94.2237

been computed. The results are presented in Table 3-2.As can be seen, the estimated model of order 9 gives a very good accuracy, its output VAFsbeing comparable to the the ones of the higher order estimates. This is a very good reason touse the order 9 model estimate, as it reduces system complexity and, at the same time, com-putation time for the rest of the operations, such as estimate optimization, future controllercomputations (a system’s model is estimated so that a controller can be designed afterwards)etc.

3-8 Model Optimization

Using the initial estimated (Ai, Bi, Ci, Di,Ki) matrices, the model is through an optimizationalgorithm so that better results can be obtained. This is achieved through the use of theprovided MATLAB toolbox command doptlti. The obtained model matrices are give by:

Ao =

0.7724 0.7935 0.1698 0.107 0.1296 −0.2650 −0.1336 0.0374 0.3688−0.7920 0.6872 −0.1471 0.0899 0.0351 −0.1153 0.0925 0.0610 0.32060.0337 0.0122 0.9382 0.0448 −0.1057 −0.0803 0.0207 0.0516 0.14210.0929 0.1910 0.3808 0.8952 0.1502 0.2970 0.0050 0.0101 0.1580

−0.0605 −0.0489 0.1664 −0.0404 0.9939 0.0251 0.0151 −0.0543 −0.0050−0.1919 0.2100 −0.1458 −0.2375 0.0054 0.8045 0.2785 −0.0420 −0.2024−0.0078 −0.0195 0.3554 −0.0923 −0.0404 0.0707 0.1141 −0.7133 −0.04530.1477 0.0034 −0.4658 0.0546 −0.1428 −0.0705 0.9261 0.3279 −0.0087

−0.0508 0.0477 −0.0049 −0.0717 0.0481 0.0242 −0.0725 0.0129 0.9184

Bo =

0.0007 0.00000.0011 0.00110.0026 −0.0008

−0.0062 −0.00100.0028 0.0028

−0.0030 0.00130.0174 0.01380.0082 0.0122

−0.0013 −0.0013

12

Page 17: Filtering and System Identification - Project Report

3-8 Model Optimization 13

−3000 −2000 −1000 0 1000 2000 3000−1000

0

1000

2000

−3000 −2000 −1000 0 1000 2000 3000−2000

0

2000

4000

−3000 −2000 −1000 0 1000 2000 3000−1000

0

1000

2000

−3000 −2000 −1000 0 1000 2000 3000−1000

0

1000

2000

Lag

Figure 3-5: The auto-correlation function the optimized system.From top to bottom: outputs 1 to 4.

Co =

0.2020 −0.2522 0.2812 −0.2393 0.1023 0.3575 0.0723 0.1073 −1.17870.1542 −0.2048 −0.2983 0.0734 −0.2876 0.1158 −0.0334 0.7015 0.2465

−0.4502 0.2364 −0.0584 −0.3457 −0.0774 −0.1791 0.1279 0.5601 0.0420−0.4579 0.2260 −0.0498 −0.3501 −0.0713 −0.1689 0.1247 0.5389 0.0594

Do =

0.0088 0.00700.0019 0.00380.0015 0.0003

−0.0005 0.0011

Ko =

0.2944 −0.2694 −0.3719 −0.0525−0.3286 0.3281 0.2746 0.02590.8820 −0.2919 0.5999 −1.3204

−0.2048 −0.3820 0.0147 −0.23190.3168 0.0674 0.1973 −0.60100.2226 −0.2087 −0.4069 0.3511

−0.2730 0.5600 −0.2664 0.2181−0.4411 0.5226 0.1155 1.3118−1.0180 −0.2229 0.7588 −0.6026

The optimized model estimate gives better VAFs: 98.6287, 98.1546, 99.2903, 99.2927[], whichis a significat increase in model accuracy. This can be also observed in the auto-correlationand cross-correlation plots presented in Figure 3-5 and Figure 3-6.

13

Page 18: Filtering and System Identification - Project Report

14 Model Estimation, Validation and Optimization

−5000 0 5000

−6

−4

−2

0

2

4

6

x 104

−5000 0 5000−6

−4

−2

0

2

4

6x 10

4

−5000 0 5000−5

0

5x 10

4

−5000 0 5000−1

−0.5

0

0.5

1x 10

5

−5000 0 5000

−4

−2

0

2

4

x 104

−5000 0 5000

−3

−2

−1

0

1

2

3

4x 10

4

−5000 0 5000

−4

−2

0

2

4

x 104

−5000 0 5000

−4

−2

0

2

4

x 104

Lag

Figure 3-6: The cross-correlation function the optimized system.From top to bottom: outputs 1 to 4.

14

Page 19: Filtering and System Identification - Project Report

Chapter 4

Conclusion

The task at hand was to identify the real life system as presented in the introduction. Throughdata pre-processing, model estimation and model validation, an accurate data set has beenidentified, modeled and optimized.

Firstly, the data sets have been pre-processed after which four out of seven datasets have beendiscarded for various reasons. Through a simple analysis of the datasets in terms of runningtime and sampling frequency, datasets 5 and 6 were discarded due to short running times ofonly 0.75s and 0.5s respectively. Such short running times of gathering experimental data aretoo short to analyze the slower dynamics of the system.

Consecutively, the remaining four datasets have been analyzed using spectrum analysis. Thepower spectra found showed that a rather low power and low output amplitude can be ob-served for data set 4. This gives an indication that this data set can be highly sensible tonoise, thus it is not as reliant as the rest.

With only three datasets remaining the final pre-processing started by detrending and com-pressing the data after which the order is estimated through singular value analysis, showingan order of around 9-16. Considering this fact, a Hankel matrix test shows that the inputsused in data set 2 are non persistently exciting of sufficient order and as such it is discarded.

Continuing, the model’s state-space matrices have been estimated and validated. Further-more, auto- and cross-correlation tests could be processed for datasets 1 and 7. This showedthat for dataset 7, the residual sequence of the estimated model is not a zero-mean white-noisesequence and the cross-correlation is higher than the one obtained from dataset 1. As suchthe 7th dataset is also discarded and we are left with solely dataset 1.

Finally, the model is optimized to improve accuracy which is analyzed using the VAF-values.For the first output an increase of about 8% is found and for the second output and increaseof about 6% is found.

15

Page 20: Filtering and System Identification - Project Report

16 Conclusion

16

Page 21: Filtering and System Identification - Project Report

Appendix A

Identification Matlab Script

As explained in Chapter 2, the datasets have been preprocessed using the following MATLABscript. Upon its completion, the results have been used as argument to reject several sets.

1 clc ;2 clear all ;3 close all ;45 load (’datasets.mat’ )67 % data3 - clipped (outputs saturated)8 % data6 - short experiment9 % data5 - not enough information

10 % data2 - not persistently exciting11 % data4 - low power (spectrum), low amplitude (more sensible to noise12 % disturbances), not as dense13 % data7 - corellation is not good1415 u = [ ] ;16 y = [ ] ;17 t = [ ] ;1819 u_val = [ ] ;20 y_val = [ ] ;21 t_val = [ ] ;2223 % Split data for cross -validation24 for i = 1:725 data = eval ( sprintf (’data%d’ , i ) ) ;2627 N = length ( data ) ;2829 % Get identification data30 u{i} = data ( 6 : 7 , 1 : floor (2∗ N/3) ) ’ ;31 y{i} = data ( 2 : 5 , 1 : floor (2∗ N/3) ) ’ ;

17

Page 22: Filtering and System Identification - Project Report

18 Identification Matlab Script

32 t{i} = data (1 , 1 : floor (2∗ N/3) ) ’ ;3334 % Get evaluation data35 u_val{i} = data ( 6 : 7 , floor (2∗ N/3)+1:N ) ’ ;36 y_val{i} = data ( 2 : 5 , floor (2∗ N/3)+1:N ) ’ ;37 t_val{i} = data (1 , floor (2∗ N/3)+1:N ) ’ ;38 end3940 %% Plot data41 % Input42 figure (’Position’ , [ 400 150 820 425 ] ) ;43 for i = 1:744 N = length ( data ) ;4546 subplot (7 , 2 , 2∗i−1)47 plot (t{i} , u{i } ( : , 1) ) ;48 grid on ;4950 subplot (7 , 2 , 2∗i )51 plot (t{i} , u{i } ( : , 2) ) ;52 grid on ;53 end5455 % Output56 figure (’Position’ , [ 400 150 820 425 ] ) ;57 for i = 1:758 subplot (7 , 4 , 4∗i−3)59 plot (t{i} , y{i } ( : , 1) ) ;60 grid on ;6162 subplot (7 , 4 , 4∗i−2)63 plot (t{i} , y{i } ( : , 2) ) ;64 grid on ;6566 subplot (7 , 4 , 4∗i−1)67 plot (t{i} , y{i } ( : , 3) ) ;68 grid on ;6970 subplot (7 , 4 , 4∗i )71 plot (t{i} , y{i } ( : , 4) ) ;72 grid on ;73 end7475 %% Eliminate data3 , data5 and data676 u{3} = [ ] ; u{5} = [ ] ; u{6} = [ ] ;77 y{3} = [ ] ; y{5} = [ ] ; y{6} = [ ] ;7879 u_val{3} = [ ] ; u_val{5} = [ ] ; u_val{6} = [ ] ;80 y_val{3} = [ ] ; y_val{5} = [ ] ; y_val{6} = [ ] ;8182 u = u (~cellfun (’isempty’ , u ) ) ;83 y = y (~cellfun (’isempty’ , y ) ) ;84

18

Page 23: Filtering and System Identification - Project Report

19

85 u_val = u_val (~cellfun (’isempty’ , u_val ) ) ;86 y_val = y_val (~cellfun (’isempty’ , y_val ) ) ;8788 %% Obtain signal spectrum89 figure (’Position’ , [ 400 150 820 425 ] ) ;90 for i = 1:491 subplot (1 , 4 , i ) ;92 pwelch (y{i}) ;93 end9495 %% Eliminate data496 ud{3} = [ ] ;97 yd{3} = [ ] ;9899 ud_val{3} = [ ] ;

100 yd_val{3} = [ ] ;101102 ud = ud (~cellfun (’isempty’ , ud ) ) ;103 yd = yd (~cellfun (’isempty’ , yd ) ) ;104105 ud_val = ud_val (~cellfun (’isempty’ , ud_val ) ) ;106 yd_val = yd_val (~cellfun (’isempty’ , yd_val ) ) ;107108 %% Detrend data109 ud = [ ] ;110 yd = [ ] ;111112 ud_val = [ ] ;113 yd_val = [ ] ;114115 for i = 1:3116 ud{i} = detrend (u{i}) ;117 yd{i} = detrend (y{i}) ;118119 ud_val{i} = detrend ( u_val{i}) ;120 yd_val{i} = detrend ( y_val{i}) ;121 end122123 %% Check singular values to obtain an estimate of the system order124 s = 30 ;125 R = [ ] ;126127 figure (’Position’ , [ 400 150 820 425 ] ) ;128 for i = 1:3129 [ S , R{i } ] = dordpo (ud{i} , yd{i} , s ) ;130131 subplot (1 , 4 , i )132 semilogy (S , ’*’ ) ;133 grid on ;134 end135136 %% Obtain Hankel matrices of the inputs (check if U is rank 9 -> input is137 % persistently exciting)

19

Page 24: Filtering and System Identification - Project Report

20 Identification Matlab Script

138 n = 9 ;139 s = 3∗n ;140 r = [ ] ;141142 for i = 1:3143 N = length (ud{i}) ;144 U1 = hankel (ud{i } ( 1 : s , 1) , ud{i}(s : N , 1) ) ;145 U2 = hankel (ud{i } ( 1 : s , 2) , ud{i}(s : N , 2) ) ;146 r (i , 1) = rank (U1 ) ;147 r (i , 2) = rank (U2 ) ;148149 if r (i , 1) ~= s150 str = sprintf (’Data set %d is not good’ , i ) ;151 disp ( str ) ;152 end153154 if r (i , 2) ~= s155 str = sprintf (’Data set %d is not good’ , i ) ;156 disp ( str ) ;157 end158 end159160 r161162 %% Eliminate data2163 ud{2} = [ ] ;164 yd{2} = [ ] ;165166 ud_val{2} = [ ] ;167 yd_val{2} = [ ] ;168169 ud = ud (~cellfun (’isempty’ , ud ) ) ;170 yd = yd (~cellfun (’isempty’ , yd ) ) ;171172 ud_val = ud_val (~cellfun (’isempty’ , ud_val ) ) ;173 yd_val = yd_val (~cellfun (’isempty’ , yd_val ) ) ;174175 %% PO-MOESP Subspace Identification176 yi = [ ] ;177178 for i = 1:2179 [ S , R ] = dordpo (ud{i} , yd{i} , s ) ;180 [ Ai , Ci , Ki ] = dmodpo (R , n ) ;181 [ Bi , Di ] = dac2bd (Ai , Ci , ud{i} , yd{i}) ;182183 Ae = Ai−Ki∗Ci ;184 Be = [ Bi−Ki∗Di Ki ] ;185 Ce = Ci ;186 De = [ Di −eye (4 , 4) ] ;187188 % Obtain residual vector189 epsilon{i} = dltisim (Ae , Be , Ce , De , [ ud{i} yd{i } ] ) ;190 end

20

Page 25: Filtering and System Identification - Project Report

21

191192 %% Obtain the auto-correlation plots193 maxlag = 3000 ;194195 for i = 1:2196 figure (’Position’ , [ 400 150 820 425 ] ) ;197198 for j = 1:4199 aci = xcorr ( epsilon{i } ( : , j ) , epsilon{i } ( : , j ) , maxlag ) ;200 subplot (4 , 1 , j )201 plot(−maxlag : maxlag , aci ) ;202 grid on ;203 end204 end205206 %% Obtain the cross -correlation plots207 for i = 1:2208 figure (’Position’ , [ 400 150 820 425 ] ) ;209210 for j = 1:4211 xci = xcorr ( epsilon{i } ( : , j ) , ud{i } ( : , 1) , maxlag ) ;212 subplot (2 , 4 , 2∗j−1)213 plot(−maxlag : maxlag , xci ) ;214 grid on ;215216 xci = xcorr ( epsilon{i } ( : , j ) , ud{i } ( : , 2) , maxlag ) ;217 subplot (2 , 4 , 2∗j )218 plot(−maxlag : maxlag , xci ) ;219 grid on ;220 end221 end222223 %% Eliminate data7224 ud{2} = [ ] ;225 yd{2} = [ ] ;226227 ud_val{2} = [ ] ;228 yd_val{2} = [ ] ;229230 ud = ud (~cellfun (’isempty’ , ud ) ) ;231 yd = yd (~cellfun (’isempty’ , yd ) ) ;232233 ud_val = ud_val (~cellfun (’isempty’ , ud_val ) ) ;234 yd_val = yd_val (~cellfun (’isempty’ , yd_val ) ) ;235236 %% Obtain VAFs237 n = 9 : 1 6 ;238239 for i = 1 : length (n )240 s = 3∗n (i ) ;241242 [ S , R ] = dordpo (ud {1} , yd {1} , s ) ;243 [ Ai , Ci , Ki ] = dmodpo (R , n ) ;

21

Page 26: Filtering and System Identification - Project Report

22 Identification Matlab Script

244 [ Bi , Di ] = dac2bd (Ai , Ci , ud {1} , yd {1}) ;245246 Ae = Ai−Ki∗Ci ;247 Be = [ Bi−Ki∗Di Ki ] ;248 Ce = Ci ;249 De = [ Di zeros ( 4 , 4 ) ] ;250 % Simulate the identified system251 yi{i} = dltisim (Ae , Be , Ce , De , [ ud_val{1} yd_val {1} ] ) ;252253 % Calculate the VAF254 disp (’VAF for order ’ ) ; n (i )255 vaf_po = vaf ( yd_val {1} , yi{i})256 end257258 %% Run optimization for model of order 9259 n = 9 ;260 s = 3∗n ;261262 [ S , R ] = dordpo (ud {1} , yd {1} , s ) ;263 [ Ai , Ci , Ki ] = dmodpo (R , n ) ;264 [ Bi , Di ] = dac2bd (Ai , Ci , ud {1} , yd {1}) ;265266 [ Ao , Bo , Co , Do , ~ , Ko ] = doptlti (ud {1} , yd {1} , Ai , Bi , Ci , Di , [ ] , Ki ) ;267268 Ae = Ai−Ki∗Ci ;269 Be = [ Bi−Ki∗Di Ki ] ;270 Ce = Ci ;271 De = [ Di zeros ( 4 , 4 ) ] ;272 % Simulate the identified system273 yic = dltisim (Ae , Be , Ce , De , [ ud_val{1} yd_val {1} ] ) ;274275276 Aeo = Ao−Ko∗Co ;277 Beo = [ Bo−Ko∗Do Ko ] ;278 Ceo = Co ;279 Deo = [ Do zeros ( 4 , 4 ) ] ;280 % Simulate the optimized system281 yoc = dltisim (Aeo , Beo , Ceo , Deo , [ ud_val{1} yd_val {1} ] ) ;282283 % Calculate the VAF284 disp (’VAF non-optimized’ ) ;285 vaf_po = vaf ( yd_val {1} , yic )286 disp (’VAF optimized’ ) ;287 vaf_po = vaf ( yd_val {1} , yoc )288289 %% Obtain auto and cross -correlation for optimized system290 Ae = Ao−Ko∗Co ;291 Be = [ Bo−Ko∗Do Ko ] ;292 Ce = Co ;293 De = [ Do −eye (4 , 4) ] ;294295 % Obtain residual vector296 epsilon = dltisim (Ae , Be , Ce , De , [ ud{1} yd {1} ] ) ;

22

Page 27: Filtering and System Identification - Project Report

23

297298 figure (’Position’ , [ 400 150 820 425 ] ) ;299300 for j = 1:4301 aci = xcorr ( epsilon ( : , j ) , epsilon ( : , j ) , maxlag ) ;302 subplot (4 , 1 , j )303 plot(−maxlag : maxlag , aci ) ;304 grid on ;305 end306307 figure (’Position’ , [ 400 150 820 425 ] ) ;308 for j = 1:4309 xci = xcorr ( epsilon ( : , j ) , ud {1} ( : , 1) , maxlag ) ;310 subplot (2 , 4 , 2∗j−1)311 plot(−maxlag : maxlag , xci ) ;312 grid on ;313314 xci = xcorr ( epsilon ( : , j ) , ud {1} ( : , 2) , maxlag ) ;315 subplot (2 , 4 , 2∗j )316 plot(−maxlag : maxlag , xci ) ;317 grid on ;318 end

23

Page 28: Filtering and System Identification - Project Report

24 Identification Matlab Script

24

Page 29: Filtering and System Identification - Project Report

Bibliography

[1] M. Verhaegen, V. Verdult, and N. Bergboer, Filtering and System Identification: AnIntroduction to using Matlab Software. Delft University of Technology, August 2007.

[2] M. Verhaegen and V. Verdult, Filtering and System Identification. Cambridge UniversityPress, 2007.

25