Académique Documents
Professionnel Documents
Culture Documents
Contents
List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.1
Motivation
1.2
Objective
1.3
Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1
2.2
2.3
11
2.4
12
Data Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1
13
3.2
13
3.3
14
Linear Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1
20
4.2
20
4.3
Toy Example
21
4.4
24
4.5
25
4.6
N4SID algorithm
26
Nonlinear Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.1
NARMAX
29
5.2
31
5.3
31
6.1
35
6.2
Final Comments
36
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
R Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
MATLAB
List of Figures
2.1
2.2
2.3
3.1
First hands on data. [a] shows the hovering movement of the aircraft in
earth coordinates, [b],[c],[d] show the inputs and outputs of the data. . . .
Pairwise coherence of input with outputs. Top to bottom: coherence for
elevator input, coherence for aileron input and coherence for rudder input
Power-spectrum of inputs and outputs. From left to right: power spectrum
of elevator, aileron and rudder; power spectrum of pitch, yaw and roll . .
Pair-wise cross correlation between inputs and outputs. From left to right:
cross-correlation with respect to elevator, aileron and rudder . . . . . . .
Pairwise scatterplots. From top to down: elevator-pitch system, aileron-roll
system and rudder-yaw system . . . . . . . . . . . . . . . . . . . . . . .
Partition of data for outputs for estimation and validation purposes . . . .
Partition of data for inputs for estimation and validation purposes . . . . .
3.2
3.3
3.4
3.5
3.6
3.7
4.1
4.2
4.3
4.4
4.5
. . .
. . .
with
. . .
. . . . . . . 10
. . . . . . . 10
tractor
. . . . . . . 11
. . . 14
. . . 15
. . . 15
. . . 17
. . . 18
. . . 19
. . . 19
Frequency domain identification. Notice the first subplot shows the magnitude of the response while the second one is phase of the response. . . . .
Estimation of output using MIMO least squares algorithm. The fits are not
great, interesting though . . . . . . . . . . . . . . . . . . . . . . . . . . .
Estimation of output for validation input. The fits become worse as expected
FFT of fit-error for MIMO system. High peaks are seen at 0 frequency . . .
Application of the MIMO least squares algorithm on a known linear system.
The algorithm looks perfectly alright . . . . . . . . . . . . . . . . . . . . .
. . 21
. . 22
. . 22
. . 23
. . 23
6
4.6
4.7
5.2
5.3
5.4
5.5
5.6
5.7
. . . 24
. . . 25
. . . 26
. . . 27
. . . 28
. . . 30
. . . 31
. . . 32
. . . 32
. . . 33
. . . 33
. . . 34
1. Introduction
1.1
Motivation
Developing mathematical models of physical systems based on imperfect observations or
measurements is known as system identification. System identification lets us create and
use models of dynamic systems not easily modeled from first principles or specifications.
We can use time-domain and frequency-domain input-output data to identify continuoustime and discrete-time transfer functions, process models, and state-space models.A good
practical definition of system identification is that of Zadeh [1] :
System identification is the determination, on the basis of observation of input
and output, of a system within a specified class of systems to which the system
under test is equivalent.
When the system to be modeled is an aircraft, the models are generally dynamic with
multiple inputs and outputs, and the measurements are noisy. In this project report, we wish
to identify a system from the data obtained from a fixed-wing aircraft hovering over a place.
1.2
Objective
For many applications, an aircraft can be assumed to be a rigid body, whose motion
is governed by the laws of Newtonian physics. System identification can be used to
characterize applied forces and moments acting on the aircraft that arise from aerodynamics
and propulsion. Typically, thrust forces and moments are obtained from ground tests, so
aircraft system identification is applied to model the functional dependence of aerodynamic
forces and moments on aircraft motion and control variables. We are given a set of data
obtained from a series of initial flight test to perform a hover-control of a fixed wing aircraft.
The goal is to perform several tests, analysis and experiments on the data that we learned in
the AE566 Course on Data Analysis and System Identification.
Chapter 1. Introduction
1.3
Since, the data set I am working upon is provided by someone else, I agree to allow
the data provider to read my report.
2. Data Source
2.1
2.2
10
11
Figure 2.3: Test aircraft. The tested aircraft has conventional wing-tail with tractor configuration
for example a slip in a fixed-wing aircraft.
2.3
12
2.4
3. Data Analysis
3.1
3.2
14
[a]
[b]
[c]
[d]
Figure 3.1: First hands on data. [a] shows the hovering movement of the aircraft in earth
coordinates, [b],[c],[d] show the inputs and outputs of the data.
3.3
T s = (max(time) min(time))/length(time);
(3.1)
Fs = 1/T s;
(3.2)
Then we wish to look for coherence between various inputs and outputs. This can be
R command mscohere. Results are shown in the fig 3.2. We notice
done using MATLAB
that there is strong coherence between, elevator and pitch, which is expected. However,
aileron and rudder signal do not show that much of coherence with roll and yaw respectively.
Maybe, its because of noise in the signal, or maybe its because of the feedback.
15
Figure 3.2: Pairwise coherence of input with outputs. Top to bottom: coherence for elevator
input, coherence for aileron input and coherence for rudder input
Figure 3.3: Power-spectrum of inputs and outputs. From left to right: power spectrum of
elevator, aileron and rudder; power spectrum of pitch, yaw and roll
16
Next thing we do is to find the power spectrum of each of the inputs and outputs. Powerspectrum can be seen as a way to qualify the noise content of a signal. This can be done
R . Results are shown in fig 3.3.
using periodogram command of MATLAB
Figure 3.4: Pair-wise cross correlation between inputs and outputs. From left to right:
cross-correlation with respect to elevator, aileron and rudder
Similarly, we can check for cross correlation also, using xcorr command. The results
are shown in fig 3.4
17
As we have mentioned, that our MIMO system is kind of pairwise SISO, we can figure
out how individual inputs result in individual outputs. We can show this graphically using
scatter plots. A scatter plot displays data points on a graph with inputs as abscissa and
outputs as ordinates. Scatter plots are shown in fig 3.5 .
Figure 3.5: Pairwise scatterplots. From top to down: elevator-pitch system, aileron-roll
system and rudder-yaw system
We mention in the previous section that the first thing to do is to remove the data which
corresponds to the manual mode of operation. This can be easily done using find command
R . Then, we remove the non-moving portions as doing ID on that portion
in MATLAB
may not be very sensible. This is followed by breaking the data into two portions; one for
estimation and other for validation. Fig 3.6 and fig 3.7 show this step.
18
Figure 3.6: Partition of data for outputs for estimation and validation purposes
Figure 3.7: Partition of data for inputs for estimation and validation purposes
We know our data well, and we know what kind of behavior these data should be
demonstrating since we know the source of the data. So, let us move on to the
identification.
4. Linear Identification
4.1
4.2
20
Figure 4.1: Frequency domain identification. Notice the first subplot shows the magnitude
of the response while the second one is phase of the response.
code are shown in fig 4.2 and 4.3.
Now, we check the fourier transform of the fir error of this identification. High peaks in
the plot at a certain frequency indicate that there is mismatch of dynamics at that particular
frequency. We show this plot in fig 4.4.
In the plot we can see that there are high peaks at 0 frequency, which indicate that
our DC estimates are not accurate at all. Thus, it looks like the code failed to capture the
dynamics of the data provided. But, the code itself is correct. We show in the next section
that the code works by demonstrating it on a toy example. Also, using fit-error vs prediction
error, which normally gives us a convex plot, with minima at the best possible system order,
doesnt make sense, as both the errors will be large since our estimated system is not able to
match dynamics well.
4.3
Toy Example
Using the same algorithm, we perform ID on a known system, i.e. we create input vector
and the coefficient matrix, and using them we compute our output vector. Using the MIMO
21
Figure 4.2: Estimation of output using MIMO least squares algorithm. The fits are not great,
interesting though
Figure 4.3: Estimation of output for validation input. The fits become worse as expected
22
Figure 4.4: FFT of fit-error for MIMO system. High peaks are seen at 0 frequency
least squares code, we make an estimate of the coefficient matrix. This estimated coefficient
matrix along with the input vector will give us our estimated output. We see, how much we
are able to match the estimated output to the computed output (see fig 4.5).
Figure 4.5: Application of the MIMO least squares algorithm on a known linear system.
The algorithm looks perfectly alright
Looks like we did well. To confirm that we are not missing any of the dynamics, we
show that the fft of fit error for the toy example doesnt have high peaks anywhere (see fig
23
4.6). Then why didnt the algorithm work for the given data set. Probably, its not even
linear!!
Figure 4.6: FFT of fit-error for toy system. No high peaks are seen
4.4
n>0
Note that we have assumed x(0) = 0 (zero initial state or zero initial conditions). The
notation (n) denotes a qq matrix having (n) along the diagonal and zeros elsewhere.G.2
Since the system input is a q 1 vector, we may regard (n) as a sequence of q successive
input vectors, each providing an impulse at one of the input components.
24
D,
n=0
CAn1 B, n > 0
The impulse response terms CAn B for n 0 are known as the Markov parameters of the
state-space model.
Now, to identify markov parameters, we take the elev-pitch SISO system and we try
to identify it. After identification, we have an input-output model, to which if we supply
an impulse input, we get impulse response, and thus we get markov parameters. For
identification, we will use the same MIMO least squares code. The results are shown in fig
4.7 and fig 4.8
Figure 4.7: Estimation of output for elevator-pitch SISO system. Again, estimation looks a
bit off.
Since, our estimated response couldnt match the original response, we can safely
assume that the impulse response obtained are also not very much accurate. But, still, we
have got our Markov parameters. We can use these markov parameters in the next section.
4.5
25
Figure 4.8: Markov parameters of the system obtained by providing impulse input to the
estimated system
Y (k + 1)
...
Y (k + 1)
H(k-1) =
..
Y (k)
Y (k + p)
..
Y (k + r)
Y (k + p + r)
response at time step k.
Now, by using singular value decomposition (SVD) followed by some analytical calculations we come up with a minimal state space system producing same markov parameters
as those were used to form the Hankel Matrix. We also know that the similar state space
systems have same markov parameters and same transfer functions, so, basically, we have
estimated our transfer function. It is also possible to estimate the order of the system through
ERA.
We use our elev-pitch SISO system to perform ERA upon. Now, we have two sources
of Markov parameters : we can get it by the impulse response of the estimated system we
developed in last section; also, we can get it by inverse Fourier transform of the complex
frequency response we computed in section on frequency domain identification. Let us use
the second method. The result for order 3, which we find to be most satisfactory, is shown
in the fig 4.9. Thus we can make aguess about the system order to be 3.
4.6
N4SID algorithm
In this section we try our hands on N4SID algorithm, which is based on subspace identification methods and is very popular in linear identification. The subspace identification
26
27
problem is: given a set of input/output measurements, estimate the system matrices (A, B,
C, D), Kalman filter gain K up to within a similarity transformation, and the innovation
R comman n4sid, we try to find a fit for our 3 inputcovariance matrix R. Using MATLAB
3 output system. Assuming various model orders is possible in n4sid; we present estimates
for order 3 (best than others) in fig 4.10.
Figure 4.10: Application of N4SID algorithm on our data set. Looks like N4SID barely
manages to stick to the mean value of the response
It looks like N4SID algorithm can only give mean value response, which is kind of
better, as we are more interested in fluctuations. But, there must be some better way!
R
Although, most of our methods could not live up to the expectation, but still, we have
got many insights about the system we wish to identify. The results of this section
indicate presence of non-linearity in the system, the prospects of which we explore in
the next section.
5. Nonlinear Identification
So far, we have tried our best to identify the system from the provided data. We did identify
some systems, but the fits are not satisfactory. We have also speculated the presence of
non-linearity in the system leading to failure of our linear least squares method. Hence, we
move to nonlinear identification.
5.1
NARMAX
The nonlinear auto-regressive moving average model with exogenous inputs (NARMAX
model) can represent a wide class of nonlinear systems, and is defined as
y(k) = F[y(k 1), . . . , y(k ny ), u(k d), . . . , u(k d nu ), e(k 1), . . . , e(k ne )] + e(k)
(5.1)
where y(k), u(k) and e(k) are the system output, input, and noise sequences respectively;
F[.] is some nonlinear function, d is a time delay typically set to d = 1; maximum lags for
the system output, input and noise are denoted by ny , nu , ne .
The model is essentially an expansion of past inputs, outputs and noise terms. Because
the noise is modelled explicitly unbiased estimates of the system model can be obtained in
the presence of unobserved highly correlated and nonlinear noise [5].
In our algorithm, we use several radial basis functions centered at several points on
a grid determined by range of input and output. Such radial basis functions together can
mimic system behavior provided proper scaling. Determining scale factors for each of the
functions is again a matter of least squares. We use this algorithm on our data for estimation
and data for validation as well. Results are shown in the fig 5.1.
5.1 NARMAX
29
Figure 5.1: NARMAX model structure algorithm on elev-pitch system. From top to bottom:
NARMAX algorithm on estimation data; estimation of output from derived model structure
for validation data
30
5.2
Figure 5.2: Input augmentation using basis functions on data for estimation for elev-pitch
SISO system. From left to right: measured output and estimated output, scatter plots for
measured output and estimated output
The fits look good, and now we can try the obtained model for the data for validation
(see fig 5.3). For vaildation data, the fits, as always, are not too great, but are satisfactory
though.
5.3
ze =
zv =
mhw1
x0 =
i d d a t a ( p i t c h _ e , e l e v _ e , Ts , Name , e l e v p i t c h ) ;
i d d a t a ( p i t c h _ v , e l e v _ v , Ts , Name , e l e v p i t c h ) ;
= nlhw ( ze , [ 3 3 0 ] , p w l i n e a r , p w l i n e a r ) ;
f i n d s t a t e s ( mhw1 , ze , [ ] , m a x i t e r , 5 0 ) ;
31
Figure 5.3: Input augmentation using basis functions on data for validation for elev-pitch
SISO system. From left to right: measured output and estimated output, scatter plots for
measured output and estimated output
p l o t ( mhw1 )
Figure 5.4: Block diagram of the Hammerstein Wiener system identification created in
Simulink
We first use the un-detrended data to create a system structure using iddata command.
Then by using nlhw command to feed data to the Hammerstein Wiener block. We do
this process first for estimation data, and after identifying the model structure we use
the validation input to create an estimation for validation input. By tweaking order and
non-linearity types, we are able to get the results as shown in fig 5.5.
Wait a second, this is interesting, looks like we are estimating the output well, its just
needs to be shifted. And we also know, doing what can help that. Yes, if we use detrended
data, we are able to eliminate this shift (see fig 5.6).
That has been a good identification. But what do we just learn about the system?
Hammerstein Wiener block allows us to interpret results of the identifications. In the code
32
Figure 5.5: Hammerstein Wiener Identification for un-detrended elev-pitch SISO system in
Simulink. From left to right: for estimation data; for validation data
Figure 5.6: Hammerstein Wiener Identification for detrended elev-pitch SISO system in
Simulink. From left to right: for estimation data; for validation data
33
we used for running the simulation block, we have assumed our both input and output
nonlinearities as piecewise linear, and the output-error model is assumed to be [3 3 0],
which indicates that there are 2 (3-1) zeros, 3 poles of the system, and there is no delay from
input to the output in terms of the number of samples. The pole-zero map of the identified
model is shown in fig 5.7.
Figure 5.7: Pole-zero map of the identified Hammerstein Wiener Model for elev-pitch SISO
system
In this report we have seen how a data-set can be analyzed and worked upon so as to
identify the dynamics behind the data. There have been several steps and several methods
in identifying the system corresponding to given data. Some of the methods worked okay, a
few worked very well; but most of them failed. This is expected, otherwise who would need
these many methods. In this section we try to comprehend why a particular method worked
and why others didnt.
6.1
35
Markov parameters are used in Eigensystem realization algorithm to make a guess on the
system order. Now, we move to non-linear identification, where, we demonstrate three
techniques by which we can estimate a non-linear system. We start with NARMAX, where
we use radial basis functions with variable centering and spread to approximate for system
output. Secondly, we try our techniques of augmenting input with basis functions and do
identification accordingly. The last thing we do is using Hammerstein Wiener block of
Simulink to identify system. We show poles and zeros of the system and the associated
non-linearity with inputs and outputs. Most of the algorithms require working knowledge
of matrix mathematics. One great source on the subject is [7].
6.2
Final Comments
Out of several things we tried in this project, we wish to discuss few of them to conclude
this report.
Let us talk about detrend first. A linear trend typically indicates a systematic increase or
decrease in the data. A systematic shift can result from sensor drift, for example. Whether it
makes sense to remove trend effects in the data often is a subjective question and it largely
depends on the objectives of our analysis. We have performed this experiment using the
both sets of data, and in a few cases removing trend has helped us to obtain better fits.
In system identification, we need to come up with a model, which we think can be a
great fit for the data we have. For assuming a model structure, some knowledge of the
dynamics of the experiment which produced the data is always helpful. However, its not
absolutely necessary. Also, we do not have to stick with the model we choose. There are
lots of options available. We can pick an ARX model, or an input-output model, or even an
output-error model. Evaluating the model parameters is the core of the system identification.
If we have an idea of the underlying dynamics of the variables of the experiment, we might
actually guess order of the system. If we do not know the order of the system, we can
always play with various system orders to pick the right one.
Another important thing is maintaining the logical flow of identification. We do not
jump straight to non-linear identification unless there are strong evidences to do so. In this
report, we show that the inaccuracies in least squares, and in the ERA help us to decide on
whether we need non-linear identification or not. And then of course, there are many ways
to do non-linear identification.
Finally, getting a perfect identification in data from real experiments is almost impossible
because of effects from noise, feedback, and sensor and actuator inaccuracies. But, perfect
identification is not really required. In control systems, with so many tools, we just dont
require a perfect system, right ? ^
7. Bibliography
[1] Zadeh, L. A., From Circuit Theory to System Theory, Proceedings of the IRE, Vol.
50, May 1962, pp. 856865
[2] http://en.wikipedia.org/wiki/Flight_dynamics
[3] http://www.mathworks.com/help/matlab/ref/detrend.html
[4] J.-N. JUANG and R. S. PAPPA. "An eigensystem realization algorithm for modal
parameter identification and model reduction", Journal of Guidance, Control, and
Dynamics, Vol. 8, No. 5 (1985), pp. 620-627. doi: 10.2514/3.20031
[5] http://en.wikipedia.org/wiki/Nonlinear_system_identification#
NARMAX_methods
[6] http://www.mathworks.com/help/ident/ref/idnlhwmodel.html
[7] Bernstein, D. (2009). Matrix mathematics. Princeton, N.J.: Princeton University Press
R Codes
A. MATLAB
sys_id_main.m: This is a big file which contains almost all the codes divided into
sections.
hammerstein_weiner_simulink_runner: code to run hammerstein_wiener_
simulation_block.
process.m: file accompanied with data set.
narmax.m: code to run NARMAX for elevator-pitch system.
basis_function_augmentation.m: code for basis function augmentation.
detrend.matandundetrend.mat: data set without and with linear trend, respectively.
hammerstein_wiener_simulation_block.slx: simulink model for HammersteinWiener system.