0% found this document useful (0 votes)
70 views44 pages

Sinusoidal System Identification Analysis

This document summarizes the results of system identification experiments using different input signals. The system was unable to be identified using a sinusoidal input with less than 3 frequencies due to insufficient excitation. A 6 sample square wave also did not provide enough excitation. However, a 12 sample and 20 sample square wave were able to correctly identify the system, though with a very large condition number, indicating issues with identifiability from the input. Increasing the period of the square wave input increased its persistency of excitation and ability to excite all system modes for identification.

Uploaded by

dashmon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views44 pages

Sinusoidal System Identification Analysis

This document summarizes the results of system identification experiments using different input signals. The system was unable to be identified using a sinusoidal input with less than 3 frequencies due to insufficient excitation. A 6 sample square wave also did not provide enough excitation. However, a 12 sample and 20 sample square wave were able to correctly identify the system, though with a very large condition number, indicating issues with identifiability from the input. Increasing the period of the square wave input increased its persistency of excitation and ability to excite all system modes for identification.

Uploaded by

dashmon
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ECE 621, Project # 2

Question 1

Qn:1 Driving System with Sinusiods


a) Input Signal Definition
A general function for the input chosen is shown below:

For the three cases analyzed, the parameters

were varied.

b) Results with one sinusoid


Parameter Value 0.01 1.00 0.00 0.00 5.00 NA NA 0.00 NA NA

For this analysis, the Batch LS algorithm was chosen, as directed. A 1000 sample sinusoidal signal was chosen for this analysis. Figure 1 below shows the response of the system. Note that the first 200 samples have been discarded for the system identification analysis, as directed.

ECE 621, Project # 2

Question 1

200

0.5

100

-0.5

-100

-1 0 100 200 300 400 500 600 700 800 900

-200

200

0.5

100

-0.5

-100

-1 0 100 200 300 400 500 Samples 600 700 800 900

-200

Figure 1 1-Sine Response

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 1 Sinusoid 0.7867 -4.0551 1.5249 -76.0945 504.1890 -336.1260 Condition Number Of Data Matrix

4.2589e+21

With one sinusoid, the system was not identified.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 1

c) Results with two sinusoids


Parameter Value 0.01 1.00 1.00 0.00 5.00 2.00 NA 0.00 NA

For this analysis, the Batch LS algorithm was chosen, as directed. A 1000 sample sinusoidal signal was chosen for this analysis. Figure 1 below shows the response of the system. Note that the first 200 samples have been discarded for the system identification analysis, as directed.

ECE 621, Project # 2

Question 1

400

200

-1

-200

-2 0 100 200 300 400 500 600 700 800 900

-400

400

200

-1

-200

-2 0 100 200 300 400 500 Samples 600 700 800 900

-400

Figure 2 2-Sine Response

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 2 Sinusoids -3.1668 3.7274 -1.5170 140.4014 -307.9648 185.5163 Condition Number Of Data Matrix

6.5278e+20

Even with 2 sinusoids, the system was not identified.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 1

d) Results with three sinusoids


Parameter Value 0.01 1.00 1.00 1.00 5.00 2.00 1.00 0.00

For this analysis, the Batch LS algorithm was chosen, as directed. A 1000 sample sinusoidal signal was chosen for this analysis. Figure 1 below shows the response of the system. Note that the first 200 samples have been discarded for the system identification analysis, as directed.

ECE 621, Project # 2

Question 1

4 3 2 1

600 400 200 0 -200 -400 -600 -800 -1000 0 100 200 300 400 500 600 700 800 900

0 -1 -2 -3 -4

0 0

-1000 0 100 200 300 400 500 Samples 600 700 800 900

Figure 3 3-Sine Response

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 3 Sinusoids -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Condition Number Of Data Matrix

2.7145e+12

With a combination of three sinusoids, the system was identified.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 1

e) Conclusion
The persistency of the input signal used is clearly seen to affect the ability of the algorithm to identify the system. The weak/strong persistency order (PE) of a sinusoidal signal is shown to be 2. In order that the Data Matrix has full rank, (in this case 6, since there are 6 parameters to be identified), it means that the input sequence must have a PSE of at least 6. Input Type 1 Sinusoid Order of P.E. 2 Identifiability < 6, Not Identifiable Condition Number of Q 4.2589e+21 Comment Does not meet the Identifiability requirement. This is seen from the large condition number. Does not meet the Identifiability requirement. This is seen from the large condition number. Meets the Identifiability requirement. The condition number is still large due to the sinusoidal input, however the matrix is invertible

2 Sinusoids

< 6, Not Identifiable

6.5278e+20

3 Sinusoids

>= 6, Identifiable

2.7145e+12

ECE 621, Project # 2

Question 1

g) Code
% % % % % % % ECE 621, Systems Identification Project # 2, Qn 01 Author: Date: 2012.10.30

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % % t u u u y Batch estimation Drive system with random input and get output vector. = ([Link]); = 0 + 1*sin(2*pi*5*0.01*t); = u + 0*sin(2*pi*2*0.01*t + pi/6); = u + 0*sin(2*pi*1*0.01*t - pi/12); = g_proj_1(u);

% Length of input/output vector num = length(u); % Samples to discard discard = 200; % Length of theta_hat vector = m + n m = 3; n = 3; % Initialize Phi Matrix phi = zeros(num-discard+1, m+n); % Define regressor phi' % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3)] for i = discard : num i1 = i-1;

ECE 621, Project # 2


i2 = i-2; i3 = i-3; if i1<= 0 y1 = 0; u1 = 0; end if i2<= 0 y2 = 0; u2 = 0; end if i3<= 0 y3 = 0; u3 = 0; end

Question 1

if (i1 >0 && i2>0 && i3>0) y1 = y(i1); y2 = y(i2); y3 = y(i3); u1 = u(i1); u2 = u(i2); u3 = u(i3); end phi(i,:) = [-y1 -y2 -y3 u1 u2 u3]; end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat); figure; subplot(211); [AX,H1,H2] = plotyy(t,u,t,y); grid on; set(AX(1), 'xlim', [0 t(num)]); set(AX(2), 'xlim', [0 t(num)]); ax1y = get(AX(1), 'ylim'); ax2y = get(AX(2), 'ylim'); set(get(AX(1),'ylabel'), 'string', 'Input'); set(get(AX(2),'ylabel'), 'string', 'Output'); clear AX; subplot(212); [AX,H1,H2] = plotyy(t(discard:num), u(discard:num),t(discard:num), y(discard:num)); grid on; set(AX(1), 'xlim', [0 t(num)]); set(AX(2), 'xlim', [0 t(num)]); set(AX(1), 'ylim', ax1y); set(AX(2), 'ylim', ax2y); set(get(AX(1),'ylabel'), 'string', 'Input considered for I/D'); set(get(AX(2),'ylabel'), 'string', 'Output considered for I/D'); xlabel('Samples');

ECE 621, Project # 2

Question 2

Qn:2 Driving System with Symmetric Square waveforms


h) Results with Period = 6 samples
1

0.5

Input

-0.5

-1 0 5 10 15 20 25 30 35

60

40

Output

60
20

0.5

40

-20 0 5 10 15 Samples 20 25 30 35

20

-0.5

Figure 4 Response with 6 sample symmetric square wave


-20 The first 2000samples (208s) of the input and output signals300 discarded400 only the rest was fed were 350 and 450 50 100 150 200 250 500 into the identifier. -1

20

0.5

10

-0.5

-10

-1 180 190 200 210 Time (s) 220 230 240

-20 250

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2

60

0.5

40

20

-0.5

-1 0 50 100 150 200 250 300 350 400 450

-20 500

20

0.5

10

-0.5

-10

-1 0 50 100 150 200 250 Time (s) 300 350 400 450

-20 500

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 6 sample sym. Sqr. wave 4.6946 -9.1376 -11.7038 -106.7417 -7.0509 98.1983 Condition Number Of Data Matrix

4.0311e+17

With a 6 sample symmetric square waveform, the system was not identified.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2

i) Results with Period = 12 samples


1

0.5

Input

-0.5

-1 0 2 4 6 8 10 12 14 16 18 20

150

100

200
50

Output

-50

0
-100 0 2 4 6 8 10 Samples 12 14 16 18 20

Figure 5 Response with 12 sample symmetric square wave


-1

The first 200 samples (104s) of the150 and output signals 300 discarded and only the rest was fed input 200 were 350 0 50 100 250 400 450 500 into the identifier.
1 100

-200

0.5

50

-0.5

-50

-1 70 80 90 100 110 Time (s) 120 130 140

-100

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2

200

-1 0 50 100 150 200 250 300 350 400 450

-200 500

100

0.5

50

-0.5

-50

-1 0 50 100 150 200 250 Time (s) 300 350 400 450

-100 500

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 12 sample sym. Sqr. wave -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Condition Number Of Data Matrix

374614.1391

With a 12 sample symmetric square waveform, the system was identified correctly.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2

j) Results with Period = 20 samples


1

0.5

Input

-0.5

-1 0 2 4 6 8 10 12 14 16 18 20

300

200

100

Output

300 250

0.8 0.6 0.4 0.2

200 150

-100

100 50
0 2 4 6 8 10 Samples 12 14 16 18

0 -0.2 -200 -0.4 -0.6 -0.8 -1

0 20 -50 -100

Figure 6 Response with 20 sample symmetric square wave

-150 -200

The first 200 samples (63s) of the input and output signals300 discarded and only 450 rest was fed into were 350 the 0 50 100 150 200 250 400 500 the identifier.
1 200

0.5

100

-0.5

-100

-1 45 50 55 60 65 Time (s) 70 75 80 85 90

-200

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2
300 250 200 150 100 50 0 -50 -100 -150

1 0.8 0.6 0.4 0.2

0 -0.2 -0.4 -0.6 -0.8 -1 0 50 100 150 200 250 300 350 400 450

-200 500

200

0.5

100

-0.5

-100

-1 0 50 100 150 200 250 Time (s) 300 350 400 450

-200 500

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with 20 sample sym. Sqr. wave -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Condition Number Of Data Matrix

800462.8466

With a 20 sample symmetric square waveform as well, the system was identified correctly.

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 2

k) Conclusion
The persistency of the input signal used is clearly seen to affect the ability of the algorithm to identify the system. The weak/strong persistency order (PE) of a symmetric square wave is known to be function of the number of samples per period. For a symmetric square wave with M samples per period, the order of persistency is M/2. In order that the Data Matrix has full rank, (in this case 6, since there are 6 parameters to be identified), it means that the input sequence must have a PSE of at least 6. Hence the input symmetric square wave shall have at least 12 samples per period. Input Type 6 sample symmetric sq. wave 12 sample symmetric sq. wave 20 sample symmetric sq. wave Order of P.E. 3 Identifiability < 6, Not Identifiable >= 6, Identifiable Condition Number of Q 4.0311e+17 Comment Does not meet the Identifiability requirement. This is seen from the large condition number. Meets the Identifiability requirement.

374614.1

10

>= 6, Identifiable

800462.8

Meets the Identifiability requirement.

ECE 621, Project # 2

Question 2

m)
. % % % % % % %

Code

ECE 621, Systems Identification Project # 2, Qn 02 Author: Date: 2012.10.30

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation % Drive system with random input and get output vector. nmp = 11; % Number of periods smp = 20; % Samples per period t = linspace(1e-10,nmp*2*pi,smp*nmp); % Symmetric Square Wave u = (2*(sin(t)>0)-1); y = g_proj_1(u); figure; subplot(211);stem(t(1:3*smp),u(1:3*smp)); grid on; ylabel('Input'); subplot(212);stem(t(1:3*smp),y(1:3*smp)); grid on; ylabel('Output'); xlabel('Samples'); % Length of input/output vector num = length(u); % Samples to discard discard = 200; % Length of theta_hat vector = m + n m = 3; n = 3;

ECE 621, Project # 2


% Initialize Phi Matrix phi = zeros(num-discard+1, m+n); for i = discard : num i1 = i-1; i2 = i-2; i3 = i-3; if i1<= 0 y1 = 0; u1 = 0; end if i2<= 0 y2 = 0; u2 = 0; end if i3<= 0 y3 = 0; u3 = 0; end

Question 2

if (i1 >0 && i2>0 && i3>0) y1 = y(i1); y2 = y(i2); y3 = y(i3); u1 = u(i1); u2 = u(i2); u3 = u(i3); end phi(i,:) = [-y1 -y2 -y3 u1 u2 u3]; end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat); figure; subplot(211); [AX,H1,H2] = plotyy(t,u,t,y); grid on; set(AX(1), 'xlim', [0 t(num)]); set(AX(2), 'xlim', [0 t(num)]); set(AX(1), 'ylim', [-1.1 1.1]); set(get(AX(1),'ylabel'), 'string', 'Input'); set(get(AX(2),'ylabel'), 'string', 'Output'); subplot(212); [AX,H1,H2] = plotyy(t(discard:num), u(discard:num),t(discard:num), y(discard:num)); grid on; set(AX(1), 'xlim', [0 t(num)]); set(AX(2), 'xlim', [0 t(num)]); set(AX(1), 'ylim', [-1.1 1.1]); set(get(AX(1),'ylabel'), 'string', 'Input considered for I/D'); set(get(AX(2),'ylabel'), 'string', 'Output considered for I/D'); xlabel('Time (s)');

ECE 621, Project # 2

Question 3

Qn:3 Over Parametrization


n) True Model
The true model for the system can be defined as follows:

An expression for y(t) in discrete time domain can then be defined as follows:

where:

and with the following parameters:


p1 p2 p3 b0 b1 b2 = = = = = = 0.80; 0.68; 0.50; 5.00; 2.00; 3.00;

Parameter a0 a1 a2 b0 b1 b2

True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000

ECE 621, Project # 2

Question 3

o) Input Used for Identification


A symmetric square wave with 20 samples per period was chosen for system identification, for all cases discussed here. This should be sufficient, since such a signal has an order of persistence of 10, and can be used to estimate up to 10 parameters. Even if an extra parameter is added to both the numerator and the denominator, the total number of parameters to be estimated would only be 8 in this case. Hence the chosen signal has sufficient order of P.E..
1

0.5

Input

-0.5

-1 0 5 10 15 20 25 30 35

300

200

100

Output

-100

-200 0 5 10 15 Samples 20 25 30 35

1 0.8 0.6 0.4 0.2

300 250 200 150 100 50 0 -50 -100 -150 -200 0 10 20 30 40 50 60 70

0 -0.2 -0.4 -0.6 -0.8 -1

200

0.5

100

-0.5

-100

-1 0 10 20 30 40 Time (s) 50 60 70

-200

Output considered for I/D

Input considered for I/D

Output

Input

ECE 621, Project # 2

Question 3

p) Extra Input Term


If the System ID model were modeled with an extra input term, the regressor
[

can be expressed as:


]

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with extra i/p parameter -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 0.0000 Condition Number Of Data Matrix

1.4112e+07

It can be seen that in this case, the least squares identifier was able to correctly identify the system and the excess parameter. The excess parameter b3 was identified as 0, as expected.

q) Extra Output Term


If the System ID model were modeled with an extra output term, the regressor
[

can be expressed as:


]

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with extra o/p parameter -1.9800 1.2840 -0.2720 -0.0000 5.0000 2.0000 3.0000 Condition Number Of Data Matrix

2711800.233

It can be seen that in this case, the least squares identifier was able to correctly identify the system and the excess parameter. The excess parameter a3 was identified as 0, as expected.

ECE 621, Project # 2

Question 3

r) Extra Term in Numerator and Denominator


If the System ID model were modeled with an extra term in the numerator and the denominator,, the regressor can be expressed as:
[ ]

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with extra i/p parameter 7.2433 -16.9782 11.5708 -2.5087 5.0000 48.1167 21.4467 27.6700 Condition Number Of Data Matrix

8.4400e+17

It can be seen that in this case, the least squares identifier was not able to identify the system. Several attempts were made to evaluate the possibility of complete system identification with the overparametrization: Increased Samples per period to upto 50 samples o No effect: System was not identified Increased total number of samples considered for identification o No effect: System was not identified Changed input to a pseudorandom signal o No effect: System was not identified. But estimates slightly better True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate -2.7020 2.7135 -1.1990 0.1964 5.0000 -1.6100 1.5560 -2.1660 Cond(Q)

5.2243e+16

s) Conclusion
Overparametrization introduces limitation to estimation of an ARMA system only if excess parameters are introduced both at the input and at the autoregressive terms. This is because it creates linear dependencies in the regressor, if extra input terms and output terms are present together.

ECE 621, Project # 2

Question 3

t) Code: (+1 param in numerator)


% % % % % % % ECE 621, Systems Identification Project # 2, Qn 03 a (+1 param in numerator) Author: Date: 2012.10.30

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation % Drive system with random input and get output vector. nmp = 12; % Number of periods smp = 20; % Samples per period t = linspace(1e-10,nmp*2*pi,smp*nmp); % Symmetric Square Wave u = (2*(sin(t)>0)-1); y = g_proj_1(u); % This will assume that the system is an ARMA model with a form as defined % as below: % y(t) = bo u(t-1) + b1 u(t-2) + b2 u(t-3) - a1 y(t-1) - a2 y(t-2) - a3 y(t3) % Goal of the batch estimator will be to find b0, b1, b2, a1, a2, & a3

% Length of input/output vector num = length(u); % Samples to discard discard = 200; % Length of theta_hat vector = m + n m = 4; n = 3;

ECE 621, Project # 2

Question 3

% Initialize Phi Matrix phi = zeros(num-discard+1, m+n); % Define regressor phi' % Add param in numerator (b4) % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3) u(t-4)] for i = discard : num % indices will be +ve as long as discard >=4 % here discard = 200 samples i1 i2 i3 i4 = = = = i-1; i-2; i-3; i-4;

y1 = y(i1); y2 = y(i2); y3 = y(i3); u1 = u(i1); u2 = u(i2); u3 = u(i3); u4 = u(i4);

phi(i,:) = [-y1 -y2 -y3 u1 u2 u3 u4];

end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat);

ECE 621, Project # 2

Question 3

u) Code: (+1 param in denominator)


% % % % % % % ECE 621, Systems Identification Project # 2, Qn 03 b (+1 param in denominator) Author: Date: 2012.10.30

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation % Drive system with random input and get output vector. nmp = 12; % Number of periods smp = 20; % Samples per period t = linspace(1e-10,nmp*2*pi,smp*nmp); % Symmetric Square Wave u = (2*(sin(t)>0)-1); y = g_proj_1(u); % This will assume that the system is an ARMA model with a form as defined % as below: % y(t) = bo u(t-1) + b1 u(t-2) + b2 u(t-3) - a1 y(t-1) - a2 y(t-2) - a3 y(t3) % Goal of the batch estimator will be to find b0, b1, b2, a1, a2, & a3

% Length of input/output vector num = length(u); % Samples to discard discard = 200; % Length of theta_hat vector = m + n m = 3; n = 4;

ECE 621, Project # 2

Question 3

% Initialize Phi Matrix phi = zeros(num-discard+1, m+n); % Define regressor phi' % Add param in numerator (b4) % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3) u(t-4)] for i = discard : num % indices will be +ve as long as discard >=4 % here discard = 200 samples i1 i2 i3 i4 = = = = i-1; i-2; i-3; i-4;

y1 = y(i1); y2 = y(i2); y3 = y(i3); y4 = y(i4); u1 = u(i1); u2 = u(i2); u3 = u(i3);

phi(i,:) = [-y1 -y2 -y3 -y4 u1 u2 u3];

end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat);

ECE 621, Project # 2

Question 3

v) Code: (+1 param in numerator & denominator)


% % % % % % % ECE 621, Systems Identification Project # 2, Qn 03 c (+1 param in num and den) Author: Date: 2012.10.30

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation % Drive system with random input and get output vector. nmp = 50; % Number of periods smp = 50; % Samples per period t = linspace(1e-10,nmp*2*pi,smp*nmp); % Symmetric Square Wave u = (2*(sin(t)>0)-1); clear u; load rand_u y = g_proj_1(u); % This will assume that the system is an ARMA model with a form as defined % as below: % y(t) = bo u(t-1) + b1 u(t-2) + b2 u(t-3) - a1 y(t-1) - a2 y(t-2) - a3 y(t3) % Goal of the batch estimator will be to find b0, b1, b2, a1, a2, & a3

% Length of input/output vector num = length(u); % Samples to discard discard = 200; % Length of theta_hat vector = m + n m = 4; n = 4;

ECE 621, Project # 2

Question 3

% Initialize Phi Matrix phi = zeros(num-discard+1, m+n); % Define regressor phi' % Add param in numerator (b4) % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3) u(t-4)] for i = discard : num % indices will be +ve as long as discard >=4 % here discard = 200 samples i1 i2 i3 i4 = = = = i-1; i-2; i-3; i-4;

y1 = y(i1); y2 = y(i2); y3 = y(i3); y4 = y(i4); u1 = u(i1); u2 = u(i2); u3 = u(i3); u4 = u(i4);

phi(i,:) = [-y1 -y2 -y3 -y4 u1 u2 u3 u4];

end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat);

ECE 621, Project # 2

Question 4

Qn:4 Effect of Feedback


The system is modeled as the following per the problem description: v(t) Plant u(t) Controller d(t) r(t) y0(t) y(t)

This can be simplified to: v(t) y0(t) y(t)

d(t)

r(t)

For the analysis, a pseudorandom sequence was used for measurement noise v(t). For the sake of comparison, the same measurement noise sequence was used for all the cases analyzed. The following table shows the list of cases that have been analysed.

Controller Type P P PI PI

Controller Reference r(t) 0 random 0 random

Measurement Noise random random random random

ECE 621, Project # 2

Question 4

w) Case 1: P Controller, r(t) = random


2 x 10 0.2 0.1 0 -0.1 100 x 10
-3

1 0 -1 -2 200 300 400 Time (s) 500 600 700

-0.2 800

1 0.5 0 -0.5 100 400 500 600 Time (s) Zoom In on Plant Output (True vs Measured), Noise Level :7.0833e-006 200 300 700 -1 800

1 0 -1 -2

0.1 0.05 0 -0.05 -0.1 750 755 760 765 770 775 Time (s) 780 785 790 795

0.1 0.05 0 -0.05 -0.1 800

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with P Controller, r(t) = random -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0001 Condition Number Of Data Matrix

42903.3689

With a measurement noise magnitude of 0.000001 (Noise Power Level of 7.083e-6 compared to Output Power), the system was identified to adequate precision, in the presence of a pseudorandom reference signal. The following table shows the effect of measurement noise on the estimates with a P controller.

Plant Measured Output (y)

Plant True Output (y )

Controller Refernce (r)

Plant Input (u)

Plant Measured Output (y)

-3

Plant Input (u)

ECE 621, Project # 2

Question 4

Table 1 Comparison of Results with a P Controller for various Measurement Noise Levels
Noise Amplitude Estimate -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2839 -0.2720 5.0000 2.0002 3.0001 -1.9790 1.2821 -0.2711 4.9997 2.0056 3.0032 -1.9096 1.1566 -0.2115 4.9958 2.3511 3.1981 -1.1454 -0.1714 0.3887 5.0249 6.1491 5.7042 -0.4081 -0.2804 -0.1290 5.2693 10.3454 15.0018 RMS Estimate Error Cond(Q) Noise to Output Ratio

1.00E-10

2.40E-09

47020.04436

6.88853E-10

1.00E-09

2.40E-08

47020.04436

6.88853E-09

1.00E-08

0.0000002

47020.04431

6.88853E-08

1.00E-07

0.0000024

47020.0438

6.88853E-07

1.00E-06

0.0000245

47020.03626

6.88853E-06

1.00E-05

0.0002843

47019.70911

6.88852E-05

0.0001

0.0068166

46991.29833

0.000688852

0.001

0.4328803

44408.34346

0.006888419

0.01

5.2706347

17059.58527

0.068871096

0.1

14.7885249

14540.0083

0.684050624

ECE 621, Project # 2

Question 4

x) Case 2: P Controller, r(t) = 0


2 x 10 x 10 1 0.5 0 -0.5 100 x 10
-9

1 0 -1 -2 200 300 400 Time (s) 500 600 700

-1 800

1 0.5 0 -0.5 100 400 500 600 Time (s) Zoom In on Plant Output (True vs Measured), Noise Level :6.308 200 300 700 -1 800 x 10 1 0.5 0 -0.5 755 760 765 770 775 Time (s) 780 785 790 795 -1 800

1 0 -1 -2

Plant True Output (y )

1 0.5 0 -0.5

x 10

-1 750

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with P Controller, r(t) = 0 -0.0407 -0.0886 -0.3442 33.2457 140.6121 -8.3892 Condition Number Of Data Matrix

1.4493e+021

With r(t) = 0, the system was not identified. This is because of the following: Controller input d(t) is: Hence Plant Input u(t):

Since the regressor is the following: there is linear dependence between u and y. Hence the data matrix is not invertible.

Plant Measured Output (y)

-7

-6

Controller Refernce (r)

Plant Input (u)

Plant Measured Output (y)

-9

-6

Plant Input (u)

ECE 621, Project # 2

Question 4

y) Case 3: PI Controller, r(t) = random


For a PI controller, the block diagram is represented as before, but the coeffients A(z) and B(z) will be different: v(t) y0(t) y(t)

d(t)

r(t)

where:

An expression for y(t) can hence be obtained as follows:

With a measurement noise magnitude of 0.000001 (Noise Power Level of 7.083e-6 compared to Output Power), the system was identified to adequate precision, in the presence of a pseudorandom reference signal.

Results True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 Estimate with PI Controller, r(t) = random -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0001 Condition Number Of Data Matrix

92529.8786

ECE 621, Project # 2

Question 4

x 10

0.2 0.1 0 -0.1 100 200 300 400 Time (s) 500 600 700 -0.2 800

1 0 -1 -2

1 0.5 0 -0.5 100 400 500 600 Time (s) Zoom In on Plant Output (True vs Measured), Noise Level :4.5487e-006 200 300 700 -1 800

1 0 -1 -2

0.2 0.1 0 -0.1 -0.2 750 755 760 765 770 775 Time (s) 780 785 790 795

0.2 0.1 0 -0.1 -0.2 800

The following table shows the effect of measurement noise on the estimates with a PI controller.

Plant Measured Output (y)

Plant True Output (y )

Controller Refernce (r)

x 10

-3

Plant Input (u)

Plant Measured Output (y)

-3

Plant Input (u)

ECE 621, Project # 2

Question 4

Table 2 Comparison of Results with a PI Controller for various Measurement Noise Levels
Noise Amplitude Estimate -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000 -1.9800 1.2839 -0.2720 5.0000 2.0002 3.0001 -1.9791 1.2824 -0.2713 4.9998 2.0049 3.0029 -1.9208 1.1775 -0.2223 5.0038 2.3037 3.1782 -1.1632 -0.1455 0.3732 5.1671 6.2032 5.7588 -0.4577 -0.3035 -0.1117 7.3639 12.0901 16.4930 RMS Estimate Error Cond(Q) Noise to Output Ratio

1.00E-10

2.22E-09

97123.60802

4.51E-10

1.00E-09

2.20E-08

97123.60803

4.51E-09

1.00E-08

0.0000002

97123.60809

4.51E-08

1.00E-07

0.0000022

97123.60867

4.51E-07

1.00E-06

0.0000224

97123.61018

4.51E-06

1.00E-05

0.0002580

97123.19356

4.51E-05

0.0001

0.0059687

97075.89533

0.000451

0.001

0.3759261

92591.31712

0.004508

0.01

5.3322007

35372.40991

0.045086

0.1

17.1558106

27309.19736

0.449590

ECE 621, Project # 2

Question 4

z) Case 4: P Controller, r(t) = 0


With r(t) = 0 , the LS identifier will not be able to identify the parameters due to the linear dependency introduced in the regressor by the PI controller. Since r(t) = 0, the plant input u(t) is:

or

Since the regressor is the following: there is linear dependence between u and y. Hence the data matrix is not invertible. Results
2 x 10 x 10 1 0.5 0 -0.5 100 x 10
-9

1 0 -1 -2 200 300 400 Time (s) 500 600 700

-1 800

1 0.5 0 -0.5 100 400 500 600 Time (s) Zoom In on Plant Output (True vs Measured), Noise Level :4.1584 200 300 700 -1 800 x 10 1 0.5 0 -0.5 755 760 765 770 775 Time (s) 780 785 790 795 -1 800

1 0 -1 -2

Plant True Output (y )

2 1 0 -1

x 10

-2 750

True value -1.9800 1.2840 -0.2720 5.0000 2.0000 3.0000

Estimate with PI Controller, r(t) = 0 -0.0133 0.4766 -1.6467 -183.7949 669.0858 -41.7854

Condition Number Of Data Matrix

8.7032e+022

Plant Measured Output (y)

-7

-6

Controller Refernce (r)

Plant Input (u)

Plant Measured Output (y)

-9

-6

Plant Input (u)

ECE 621, Project # 2

Question 4

aa)

Conclusion

It was seen that feedback introduces linear dependencies in the regressor, and hence led to singularities in the data matrix inversion calculations, if the controller reference signal was set to 0. If the controller reference signal was non-zero, and independent of u(t) and y(t), the system identifier did not have any issues estimating the parameters. Furthermore, the introduction of measurement noise was shown to significantly impact the parameter estimates. As shown in Table 1 and Table 2, the noise levels had to be significantly reduced to yield parameter estimates close to truth.

Table 3 Comparison of Results

Controller Type P P PI PI

Controller Reference r(t) 0 random 0 random

Measurement Noise random random random random

Condition Number Of Data Matrix 1.4493e+021 42903.3689 8.7032e+022 92529.8786

Estimate Not Identified Identified Not Identified Identified

ECE 621, Project # 2

Question 4

bb) Code: (P Controller)


% % % % % % % ECE 621, Systems Identification Project # 2, Qn 04 Author: Date: 2012.11.02

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation load rand_r load rand_v % Length of input/output vector num = 800; r(num+1:end)=[]; v(num+1:end)=[]; rmax = 0.0; vmax = 0.000001; rmean = -mean(r); vmean = -mean(v); t = (1:num); r = rmean*rmax + rmax*r; v = vmean*vmax + vmax*v;

for i = 1:length(r)

ECE 621, Project # 2


i1 = i-1; i2 = i-2; i3 = i-3;

Question 4

if i1<= y01 end if i2<= y02 end if i3<= y03 end

0 = 0; u1 = 0; r1 = 0; d1 = 0; y1 = 0; 0 = 0; u2 = 0; 0 = 0; u3 = 0;

if (i1 >0 && i2>0 && i3>0) y01 = y0(i1); y02 = y0(i2); y03 = y0(i3); u1 = u(i1); u2 = u(i2); u3 = u(i3); r1 = r(i1); d1 = d(i1); y1 = y(i1); end

d(i) = r(i) - y1; kp =0.0023; u(i) = kp*d(i); y0curr = [y03 y02 y01]; ucurr = [u3 u2 u1]; % Compute current output y0(i) = g_proj_1_current(ucurr, y0curr); y(i) end y = y'; % This will assume that the system is an ARMA model with a form as defined % as below: % y(t) = bo u(t-1) + b1 u(t-2) + b2 u(t-3) - a1 y(t-1) - a2 y(t-2) - a3 y(t3) % Goal of the batch estimator will be to find b0, b1, b2, a1, a2, & a3 % Samples to discard discard = 20; % Length of theta_hat vector = m + n m = 3; n = 3; = y0(i) + v(i);

ECE 621, Project # 2


% Initialize Phi Matrix phi = zeros(num-discard+1, m+n);

Question 4

% Define regressor phi' % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3)] for i = discard : num phi(i,:) = [-y(i-1) -y(i-2) -y(i-3) u(i-1) u(i-2) u(i-3)]; end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat); pnum = [t(1) t(end)]; figure; subplot(311); [AX,H1,H2] = plotyy(t,u,t,y); grid on; set(H2,'LineStyle','-.', 'Linewidth',1.2) set(AX(1), 'xlim', pnum); set(AX(2), 'xlim', pnum); set(get(AX(1),'ylabel'), 'string', 'Plant Input (u)'); set(get(AX(2),'ylabel'), 'string', 'Plant Measured Output (y)'); xlabel('Time (s)'); subplot(312); [AX,H1,H2] = plotyy(t,u,t,r); grid on; set(H2,'LineStyle','-.', 'Linewidth',1.2) set(AX(1), 'xlim', pnum); set(AX(2), 'xlim', pnum); set(get(AX(1),'ylabel'), 'string', 'Plant Input (u)'); set(get(AX(2),'ylabel'), 'string', 'Controller Refernce (r)'); xlabel('Time (s)'); subplot(313); [AX,H1,H2] = plotyy(t(num-50:num),y0(num-50:num),t(num-50:num),y(num50:num)); grid on; set(H2,'LineStyle','.') set(get(AX(1),'ylabel'), 'string', 'Plant True Output (y_0)'); set(get(AX(2),'ylabel'), 'string', 'Plant Measured Output (y)'); ttt = ['Zoom In on Plant Output (True vs Measured), Noise Level :', num2str(std(v)/std(y0))]; title(ttt) xlabel('Time (s)'); size_figs_4PPT

ECE 621, Project # 2

Question 4

cc)
% % % % % % %

Code: (PI Controller)

ECE 621, Systems Identification Project # 2, Qn 04 Author: Date: 2012.11.02

clear all; clc; close all hidden; % Display true system parameters for comparison p1 = 0.80; p2 = 0.68; p3 = 0.50; b0 = 5.00; b1 = 2.00; b2 = 3.00; a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; disp ('Theta matrix from System'); disp([a1;a2;a3;b0;b1;b2]); clear all; % Batch estimation load rand_r load rand_v % Length of input/output vector num = 800; r(num+1:end)=[]; v(num+1:end)=[]; rmax = 0.0; vmax = 0.000001; rmean = -mean(r); vmean = -mean(v); t = (1:num); r = rmean*rmax + rmax*r; v = vmean*vmax + vmax*v; for i = 1:length(r) i1 = i-1; i2 = i-2; i3 = i-3;

ECE 621, Project # 2

Question 4

if i1<= y01 end if i2<= y02 end if i3<= y03 end

0 = 0; u1 = 0; r1 = 0; d1 = 0; y1 = 0; 0 = 0; u2 = 0; 0 = 0; u3 = 0;

if (i1 >0 && i2>0 && i3>0) y01 = y0(i1); y02 = y0(i2); y03 = y0(i3); u1 = u(i1); u2 = u(i2); u3 = u(i3); r1 = r(i1); d1 = d(i1); y1 = y(i1); end

d(i) = r(i) - y1; dcurr = [d1 d(i)]; u(i) = pi_control_current(dcurr, u1); y0curr = [y03 y02 y01]; ucurr = [u3 u2 u1]; % Compute current output y0(i) = g_proj_1_current(ucurr, y0curr); y(i) end y = y'; % This will assume that the system is an ARMA model with a form as defined % as below: % y(t) = bo u(t-1) + b1 u(t-2) + b2 u(t-3) - a1 y(t-1) - a2 y(t-2) - a3 y(t3) % Goal of the batch estimator will be to find b0, b1, b2, a1, a2, & a3 = y0(i) + v(i);

% Samples to discard discard = 20; % Length of theta_hat vector = m + n m = 3; n = 3;

ECE 621, Project # 2


% Initialize Phi Matrix phi = zeros(num-discard+1, m+n);

Question 4

% Define regressor phi' % phi_t = [-y(t-1) -y(t-2) -y(t-3) u(t-1) u(t-2) u(t-3)] for i = discard : num phi(i,:) = [-y(i-1) -y(i-2) -y(i-3) u(i-1) u(i-2) u(i-3)]; end % Form Q Matrix q = phi'*phi; disp(['Condition Number of Data Matrix = ', num2str(cond(q))]); % Batch compute theta_hat with PHI matrix theta_hat = q\(phi'*y); disp ('Theta hat matrix from System Identification'); disp(theta_hat); pnum = [t(1) t(end)]; figure; subplot(311); [AX,H1,H2] = plotyy(t,u,t,y); grid on; set(H2,'LineStyle','-.', 'Linewidth',1.2) set(AX(1), 'xlim', pnum); set(AX(2), 'xlim', pnum); set(get(AX(1),'ylabel'), 'string', 'Plant Input (u)'); set(get(AX(2),'ylabel'), 'string', 'Plant Measured Output (y)'); xlabel('Time (s)'); subplot(312); [AX,H1,H2] = plotyy(t,u,t,r); grid on; set(H2,'LineStyle','-.', 'Linewidth',1.2) set(AX(1), 'xlim', pnum); set(AX(2), 'xlim', pnum); set(get(AX(1),'ylabel'), 'string', 'Plant Input (u)'); set(get(AX(2),'ylabel'), 'string', 'Controller Refernce (r)'); xlabel('Time (s)'); subplot(313); [AX,H1,H2] = plotyy(t(num-50:num),y0(num-50:num),t(num-50:num),y(num50:num)); grid on; set(H2,'LineStyle','.') set(get(AX(1),'ylabel'), 'string', 'Plant True Output (y_0)'); set(get(AX(2),'ylabel'), 'string', 'Plant Measured Output (y)'); ttt = ['Zoom In on Plant Output (True vs Measured), Noise Level :', num2str(std(v)/std(y0))]; title(ttt) xlabel('Time (s)'); size_figs_4PPT

ECE 621, Project # 2

Question 4

dd) Code: (Functions)


function y = g_proj_1_current(u, yold) p1 p2 p3 b0 b1 b2 = = = = = = 0.80; 0.68; 0.50; 5.00; 2.00; 3.00;

a1 = - (p1 + p2 + p3); a2 = p1*p2 + p2*p3 + p1*p3; a3 = - p1*p2*p3; il = length(u); ol = length(yold); y = b0*u(il) + b1*u(il-1) + b2*u(il-2) - a1*yold(ol) - a2*yold(ol-1) a3*yold(ol-2);

function u = pi_control_current(d, uold)

il = length(d); ol = length(uold);

kp =0.0023; ki =0.00023; if (il ~=2 || ol ~=1 ) disp(['i/p vector has length ', int2str(il)]); disp(['o/p vector has length ', int2str(ol)]); error ('i/p vector should have length of 2, & prev o/p vector should have length of 1'); end

u = uold + (kp + ki)*d(il) - kp*d(il-1);

You might also like