david clark final year project
DESCRIPTION
Identification of Light Gyroplane Lateral/Directional Characteristics from Flight Test Data by use of System IdentificationTRANSCRIPT
Degree of Master of Engineering in Aeronautical Engineering
Final Year Project Report
Identification of Light Gyroplane Lateral/Directional Characteristics from
Flight Test Data
David Stewart Clark
0605478
22nd May 2012
i
Abstract
The relatively small amount of research available on gyroplanes has been a cause of
concern recently due to their high accident rate and so further research into this type of
aircraft’s flight dynamics is needed. This paper focuses on the use of parameter estimation of
the lateral/directional stability derivative estimates of a gyroplane. The technique used is
system identification and the aim of this paper is to explain the use of this method noting the
many options available and steps on how to complete the process successfully. The need for
engineering judgement to be a major part of this process is also discussed. Advice on how to
implement the procedure using MATLAB system identification toolbox is also included.
ii
Nomenclature
Representations of transfer function parameters
Generic representation of a transfer function
State-space system and control matrices
State-space output equation matrices
State-space noise matrix
System disturbance error
Side force derivatives (1/ms, 1/s, etc.)
Rolling acceleration derivatives (1/ms, 1/s, etc.)
Yawing acceleration derivatives (1/ms, 1/s, etc.)
Angular velocity components about x,z body axes (rad/s)
Velocity component along the lateral body axis (m/s)
Roll and yaw angles (rad)
Trim angle (rad)
Pedal position (%) (0% fully left)
Lateral stick position (%) (0% fully left)
Output, input data
Frequency (Hz)
Model prediction error
Coherence function
Cross power spectral density (dB/Hz)
Power spectral density of (dB/Hz)
Power spectral density of (dB/Hz)
iii
Contents
1. Introduction .................................................................................................................................... 1
1.1 Background of System Identification ...................................................................................... 1
1.2 Background of Autogyros ........................................................................................................ 2
2. Identification techniques ................................................................................................................ 4
2.1 The identification process ....................................................................................................... 4
2.2 Time domain vs. Frequency domain ....................................................................................... 5
2.3 Model vs. System ................................................................................................................... 6
3. Building the identification Model Structure ....................................................................................... 7
3.1 Parametric vs. Non Parametric ............................................................................................... 7
3.2 Black Box models ................................................................................................................... 7
AR Model................................................................................................................................ 8
ARX Model ............................................................................................................................. 8
ARMAX Model ...................................................................................................................... 9
Box-Jenkins Model ................................................................................................................. 9
Output-Error Model .............................................................................................................. 10
Transfer function and state-space models ............................................................................. 10
3.3 Grey-Box Models ................................................................................................................... 11
3.4 Identification Model ............................................................................................................. 11
4. Application of System Identification ................................................................................................ 13
4.1 The Collection of Flight Data ................................................................................................. 13
4.2 Data Analysis ......................................................................................................................... 14
4.3 Data quality ........................................................................................................................... 16
4.4 Noise reduction ..................................................................................................................... 19
4.5 Constructing Initial Parameter Estimates ............................................................................. 21
4.6 Implementation of equations ............................................................................................... 21
5. Prediction Methods .......................................................................................................................... 23
5.1 Prediction Error Methods ..................................................................................................... 23
5.2 Subspace Methods ................................................................................................................ 24
5.3 Prediction Method Evaluation .............................................................................................. 24
5.4 Implementation .................................................................................................................... 25
6. Results ............................................................................................................................................... 26
6.1 Pedal-response model .......................................................................................................... 26
iv
6.2 Stick-response model ............................................................................................................ 27
6.3 The side force derivatives ..................................................................................................... 28
6.4 The rolling moment derivatives ............................................................................................ 29
6.5 Yawing moment derivatives.................................................................................................. 30
7. Discussion ...................................................................................................................................... 31
8. Conclusion ..................................................................................................................................... 33
Acknowledgements ............................................................................................................................... 34
References ............................................................................................................................................ 35
APPENDIX
1
1. Introduction
Today the autogyro is primarily used as a recreational vehicle and a low cost
alternative to a helicopter. In the early 1990’s a series of accidents highlighted safety
concerns and the Civil Aviation Authority (CAA) investigated [1]. The report concluded that
more research into the flight dynamics and handling qualities of autogyros was required.
Research teams at the University of Glasgow followed on from this report, instigating a new
boom of autogyro research, becoming world experts in the autogyro field with many of their
research findings becoming the base for further work.
1.1 Background of System Identification
System identification is a procedure used for evaluating the model of a system from
measured input-output data, i.e. it creates a link between input data and the corresponding
output data. It is used extensively in control design and within the engineering industry to
accurately define dynamic response behaviours. Within the aviation industry it is a
particularly useful tool for investigating flight performances, optimizing control system
parameters and helping to solve issues that occur during flight tests. Modern identification
techniques can estimate system models rapidly, effectively in real-time allowing engineers to
use it effectively during tests, improving efficiency of projects and making information
gathering more appropriate.
System Identification followed on the footsteps of the development of model based
control design in the 1960’s. Until the late 1950’s the techniques relied on charts and step
response analysis, plus were limited to simple single-input single-output systems. It was not
until Kalman who laid out the fundamentals of state-space control design that system
identification developed further[2].
Early Identification techniques relied heavily on statistics and econometrics. It was
not until around 1965, when two pivotal papers[3][4] were published that modern
identification was born. These two papers introduced prediction-error estimation and
subspace identification techniques (which will both be discussed later) that are the
mainstream techniques used today.
2
As the process developed system identification began to be viewed as an
approximation theory. The view originally was the need for a determination of the true
system model, but as the system identification became more established, it was seen to be
more effective to have a method that would give a model of best approximation, where model
errors could be investigated and used to help identify a best-fit model.
Further breakthroughs ensued and Ljung[5] seized on this change of attitude,
introducing the concept of bias and variance error for an estimated transfer function. This yet
again changed attitudes within the research community. More consideration was taken to
understanding the various models available and the various choices available to the user, that
if chosen correctly would lead to an improved model quality.
System identification has developed from an almost statistical method to a design
problem that requires an enormous amount of engineering judgement and skill. Constantly
developing, improving and being used extensively in control design; it has been an essential
tool in modern research and development.
1.2 Background of Autogyros
The lifting system of the autogyro rotorcraft consists essentially of a windmill whose
angular rotation is maintained by the forward speed of the aircraft[6]. The rotor motion is
fully self-generated via the relative airflow passing up through the rotor disc. This is known
as autorotation - the fundamental aspect of this type of aircraft. The blades are attached to the
shaft at a small angle of pitch to aid autorotation with the only external torque applied to the
rotor is one to begin the blade spin.
After the initial flourishing of fixed wing aircraft in the early 20th
century, the 1920’s
marked the beginning for the autogyro. Juan de la Cierva, inspired by the Wright brothers’
new technology, began building aircraft and testing new ideas[7]. After investigating low
speed flight he had come up with the idea of autorotation. Many attempts had at trying
harness this new phenomenon before a working aircraft was created. Others used his new
technology, leading to further developments and increased amount of uses [8]. Many issues
hampered the early designs and major advancements included the addition of cyclic pitch
variation instead of the previous hinged rotor blades, which made for a more efficient use of
the blades’ motions, increasing the total rotor thrust.
3
The autogyro was a precursor for the helicopter which was developed using many of
the main techniques that were discovered in the autogyro’s development. The modern
autogyro is remarkably very similar to earlier models and its secret lies in its relative
simplicity. As previously mentioned additional research into the aircraft dynamics are needed,
with robust estimates of the stability derivatives being a major focus of possible research.
4
2. Identification techniques
2.1 The identification process
The application of system identification to our gyrocopter follows the same procedure
for full sized helicopters and other rotorcraft. The identification process that will be followed
contains certain steps:
1. Collection of flight-data: The flight data is collected during specific flight
experiments that are designed to maximize the accuracy of the desired results being
obtained from during the process.
2. Data error analysis: The responses are improved by the removal of errors which
could affect the results. These errors can include bias errors, data drop-outs and data
spikes.
3. Concatenation of data: Similar responses of data are combined to increase the
amount of information available to the identification method. The more useful data
included in the process, the greater the chance of a successful identification result.
4. Background noise removal: The data is investigated to determine “useful”
frequencies and which frequencies contribute to the data noise. The unwanted
frequencies are then removed to improve the data quality.
5. Model creation: A model is created which is used by the identification algorithm as a
map to generate the outputs from the given inputs.
6. Model identification: The parameters of the prior-defined model are identified by
solving an optimization problem.
7. Model verification: Finally, the model accuracy is verified by investigating the
model response in comparison with dissimilar data, and investigation of the data
results.
The system identification process will vary between each user and there are many
various methods that can be used. The success of the process is not however related to
affixing to a certain methodology or a certain route of obtaining the results. The main
affecting property is of the level of engineering judgement that the user attains. Many
different parts of this process will be selecting which path to follow in ensuring that the best
5
result is achieved and if it is suitable for the specific situation. As well as deciding which
process to follow, it is also necessary to decide if the results are satisfactory, with models
sometimes appearing to the user as being a success, with the reality being a model full of
erroneous information.
2.2 Time domain vs. Frequency domain
System Identification can be carried out in either the frequency or time domain. Both
may be used, but as with everything in system identification a choice can be made, and
engineering judgement is the selection tool.
Data is readily collected in the time domain and this data can be used directly with the
identification process. It is simple to handle and the model is identified by matching the
predicted time histories against the measured simulated time histories. The process must start
by assuming a parametric model structure and noise model must be identified for a suitable
model to be produced.
Frequency domain identification, however, works by matching the predicted
frequency responses against the measured simulated frequency responses. The frequency data
must be first derived from time-history data by way of a Fast Fourier Transform[9].
Frequency-domain techniques have many advantages over their time domain
counterparts. Firstly, an independent measure of the data quality and system excitation can be
easily calculated from the data – the coherence function (which will be discussed later). This
metric is an important tool in system identification as it judges what range of frequencies are
appropriate to use and which contribute more to background noise. Moreover, with frequency
domain methods a fully defined model structure is not required and the user can preliminary
investigate information about the model structure (e.g. order, noise model) before identifying
a more accurate model.
Efficiency of the technique is also another important comparison. Time domain
methods use numerical integrations to evaluate parameters; this must be done in the time
domain for each iterative update in the parameters’ values. This can cause an inefficient use
of time, especially with a large data set. By comparison frequency domain algorithms are
very efficient as the responses are determined algebraically from the updated parameters[10].
Although frequency-domain methods generally give more accurate estimates
compared with time domain methods, it was decided that after investigation of the MATLAB
6
system identification toolbox, the best approach would be to use time-domain data for the
identification process. It would be also desirable to use frequency domain data as an
independent measure of the data quality, evaluating which range of data to use.
2.3 Model vs. System
A very important principle in system identification is the difference between a system
and a model[11]. The whole process is to evaluate a model of a system.
A model is a mathematical description of a system and whenever this links to a real-
life event then the model will never be able to exactly match the desired response and will
always contain errors. It is the user’s job to utilize the techniques presented to reduce these
errors and to make a “best-fit” model that describes the system as best as possible.
7
3. Building the identification Model Structure
Choosing a suitable model structure is a prerequisite before any parameter estimation
can take place. The model should produce a good comparison with the estimation data but
should not be too complex. These aspects can be somewhat contradictory and so a trade-off
must be found to contain as many important characteristics of the system as possible.
There are two core categories of modelling which can be approached; Parametric and
Non-parametric modelling.
3.1 Parametric vs. Non Parametric
Non-parametric models are concerned with characterising only the measured input-to-
output dynamics of the system and not with the internal parameters of the model. This means
that they only generate an artificial output and the computed model has no significant impact
in understanding the system’s fundamental equations. Although non-parametric modelling
contains no specific internal system information, it still provides an excellent understanding
of the key aspects of the aircraft dynamics before moving on to the more complex parametric
phase.
On the other hand, parametric models are used when the internal working of a
system’s dynamics are known, or when a pre-defined model structure is known, requiring
more of an understanding of the system and necessities a more intensive effort to model the
system. An appropriate model structure must be selected and the equations in the system
must be accurate for their parameters to be determined successfully.
3.2 Black Box models
When modelling an unknown system, there are a number of model structures
available to help with the identification process. These are parametric models which will
describe the system in terms of differential equations and transfer functions. If a black box
model structure is assumed, no attempt is made to identify the internal structure of the real
system that generates the data in the proposed identification scheme. The method only
produces a model that describes the input-output relationship of the original system[12].
8
Typical black-box model structures are described below[13][14]:
AR Model - AutoRegressive - The output of the AR model is wholly dependent on the
previous outputs. No system inputs are used. This is one of the simplest models that can
be implemented and can solve a limited amount of cases. The AR model is really a model
for a signal and not a whole system.
Equation 3.1
ARX Model - AutoRegressive with eXogenous terms - With most cases of identification
there is a requirement to include of a stimulus signal, the ARX model is the simplest that
contains a stimulus signal.
The estimation of this model is the most efficient of the polynomial estimation
methods, with solution of the ARX model always satisfying the global minimum of the
loss function. The model is appropriate for most cases, especially when the model order is
high.
There is however a disadvantage to this model. With the disturbances being built-in to
the system dynamics, the result of any identification can be affected if a poor signal-to-
noise ratio is used.
Equation 3.2
Figure 3.2 ARX model structure
Figure 3.1 AR model structure
9
ARMAX Model - AutoRegressive-Moving Average with eXogenous terms - The
ARMAX model eliminates the disadvantage of the ARX model by including the external
disturbance dynamics, which are separate from the system dynamics. Therefore this
model has the efficiency of the ARX model with the elimination of its major disadvantage.
This model is useful if dominating disturbances are affecting the system dynamics,
especially if they enter the process early on.
Equation 3.3
Box-Jenkins Model - The Box-Jenkins structure also models the disturbances separately
for the system dynamics, providing a complete model. This model is however especially
useful when disturbances occur late on in the process, such as measurement noise.
Equation 3.4
Figure 3.3 ARMAX model structure
Figure 3.4 Box-Jenkins model structure
10
Output-Error Model – This method uses no parameters in calculating the disturbance
characteristics and models the system dynamics separately from the disturbance.
Equation 3.5
Transfer Function and State-Space Models - A system can be as simple as single-input
and single-output (SISO) or up to a more complex structure with multiple-inputs and
multiple-outputs (MIMO).
Transfer functions can accurately produce a parametric model of the input-output
behaviour of a system. Transfer functions are best suited to SISO system modelling as
they become cumbersome when the order of the system increases. Stochastic parts of the
system are not evaluated and so this type of modelling is primarily used when modelling
physical systems.
For MIMO systems, which have a large number of measurements, some of the
previous models can become problematic, complicating the identification problem for the
user. For such cases a state-space model is appropriate as it allows for a more defined
model.
Equation 3.6
Generating a black-box model will provide an insight into the model structure and the
system dynamics, but more data will be needed about the system a more definitive
identification model is needed.
Figure 3.5 Output-Error model structure
11
3.3 Grey-Box Models
A model with a known internal structure, but with unknown parameters is known as a
grey-box model. The model is constructed by assuming that some of the underlying dynamics
are known. This type of structure is very useful in a dynamical identification process where
the equations of motion can be used to help create the grey-box model. This model can be
considered as a mapping from the experimental data to the estimated parameter vector[15].
3.4 Identification Model
The final decided model structure will be a grey-box state-space parametric model.
The model structure for our gyroplane is largely based on the generic lateral/directional
equations of motion. The model structure chosen has its internal structure known, but with
many of the parameter values needed to be calculated. As this paper is a first foray into
system identification techniques, it is intended to simplify the model structure as much as
possible while still maintaining enough complexities to give a useful system identification
result.
The first assumption is that the lateral/directional dynamics are uncoupled from the
longitudinal dynamics. Using this assumption we can generate the linearized stick-fixed
lateral/directional equations of motion[16]:
Equation 3.7
Simplifying again, we can disregard the yaw equation of motion as it does not have
any bearing on the overall dynamics of the aircraft as it is only proportional to the yaw rate,
should also have the empirical value of the gravitational acceleration, g, and similarly
should be consistent with the mean flight speed of the aircraft [17].The last simplification is
to assume that very negligible yaw/roll and roll/yaw coupling takes place within the aircraft
12
and so we assume and are negligible[17]. Following these simplifications, the
differential equations of motion for the lateral/directional dynamics can be given as:
Equation 3.8
13
4. Application of System Identification
4.1 The Collection of Flight Data
This paper follows on from previous research conducted by Dr. S. Houston on the VPM M16
gyroplane as shown below in figure 4.1. Flight data was provided by Dr. Houston and the full
description of the flight test experimental techniques can be found in[17].
Figure 4.1 VPM M16 gyroplane
The flight manoeuvres were commanded by the pilot via a stick controlling the
gyrocopter’s control surfaces, which initiate lateral roll and longitudinal pitch manoeuvres
and by pedal controlling the rudder, which initiate the yaw manoeuvres. It is important to try
and create an open-loop input from the controls[18] as this will give a pure representation of
the damping produced by the aircraft dynamics. It would have been impossible for the pilot to
create a pure open-loop input due to the handling qualities of the machine, as the pilot will be
consciously adding damping to his input to prevent him losing control of the aircraft. The
data was selected to reduce this pilot input to a minimum, in a bid to have purely separate
stimulus inputs.
14
The pilot had performed a variety of manoeuvres during his time in the air, including;
longitudinal stick frequency sweep and doublet inputs, lateral stick frequency sweeps and
doublet inputs and pedal frequency sweep and doublet inputs. As the main aim of this project
is to investigate the lateral/directional inputs, appropriate data must be selected. To obtain the
purest solutions the longitudinal inputs must be kept to a minimum to prevent them affecting
the lateral input excitations. Thus we will neglect all data with longitudinal stick inputs as a
major influence. It is also necessary to find data that uses the lateral stick input and pedal
inputs independently of each other. This is to allow each input’s resultant effect on the
aircraft dynamics to be modelled separately as needed to identify the flight derivatives.
As mentioned previously, this research is a follow on from previous research [17]
where the lateral/directional derivatives were investigated at speeds ~34m/s with frequency
sweep input types. This research has been requested to investigate the derivatives during low
speed fight and so this had to be taken into account when selecting useful data, initiating a
full analysis of all flight data available.
4.2 Data Analysis
Having been given access to a wide range of flight test data, an extensive examination
of the data resulted in a data set being discovered that was very appropriate to our needs. This
set contained many of the desired characteristics and is shown in Figure 4.2. The inclusion of
many lateral inputs that are unaffected by any major longitudinal input variations, along with
clearly defined separate lateral inputs at a relatively low speed, highlighted this set to be the
most workable for our purpose. Other data sets not shown had been discarded as they
contained; trim data, take-off and landing data and data with longitudinal dominance. There
was also another lateral/directional data set, but this was at a much higher flight speed
compared to the chosen data range, this will be of use later when checking the validity of the
results.
15
Figure 4.2 Raw Control Input Data of selcted flight test
This data set evidently contains many separate inputs that have no use in our
identification (longitudinal inputs, high speeds), the data must then be separated into
segments, selecting the useful parts. Signals with similar inputs were then concatenated to
allow for greater information availability for the identifying technique.
During this concatenation process, nondeterministic errors, such as dropouts and
spikes, are removed to improve the data quality. These anomalies are removed using
reconstruction techniques, investigating adjacent data and using engineering judgement to
predict what the signal value ought to be. Untreated, they can corrupt the final result of the
process, given that they show up as uncorrelated high frequency noise[10].
Trends in signals also have a similar impact on the final results as they do not average
out over the course of the data and are removed as they would cause model errors at low
frequencies and allow the analysis to concentrate on the more important aspects of the
identification[19]. The trends contained in the data were removed by use of the MATLAB
function detrend which subtracts the best-fit line (in the least-squares sense) from the data.
The de-trended and concatenated data is shown in Figure 4.3.
16
Figure 4.3 De-trended concatenated data
4.3 Data quality
The data quality can be examined by investigating the coherence function of the
values. The coherence indicates how well one output is linearly correlated with a particular
input over the examined frequency range[18]. A coherence of unity indicates that the signal is
perfectly “fine-tuned”, containing no background-noise and no bias errors with the output
signal being purely a direct result from the input stimulus. The coherence case of unity is
obviously impossible, especially in this situation due to an older mechanically controlled
aircraft being used and with experimental equipment being adjusted to fit within the craft’s
structure. It is suggested that data with a coherence function greater that 0.6 is reliable
enough to be used within the system identification process[17]; therefore this is the
benchmark that has been taken forward in this examination. This cut-off is a good measure of
the system reliability as it will take into account the many external influences that are
affecting the signal procurement during the flight. It is also wise to mention that the fly-by-
wire approach in the gyroplane’s configuration will also affect the data reliability, with push-
rods and cables being used that may not be perfectly configured or having been affected by
overuse and could affect the quality of the data.
The coherence function estimate is calculated in the frequency domain directly from
the measurement data using the equation 4.1.
17
Equation 4.1
Figures 4.4 and 4.5 are coherence plots produced after evaluation of the lateral stick
response data and pedal response data respectively. The plots compare the quality of only the
roll rate and yaw rate responses. It was deemed appropriate to investigate these two motion
responses primarily as they are the main bases for the other responses to be investigated; roll
angle and side force will also be used in this process. The coherence plots show that there is a
major correlation between roll rate to stick input and yaw rate to pedal input. This is what we
would expect as the stick input controls the ailerons of this aircraft and the pedal the aft
rudder.
This coherence results demonstrate that there is adequate relationship between
responses available in this investigation. The plots clearly show us that a significant data
range is above the coherence cut-off is available to use. The figures also covey a poorer
relationship between yaw rate due to pedal input than there is between roll rate as a result of
lateral stick input. This can be explained due to the configuration of the aircraft where the
cable controlling the rudder is more susceptible to non-linear effects than the pushrods, which
operate the rolling motion from the lateral stick[17].
Another focus of these coherence relationships is that they give further justification to
the assumption that the rudder excitation has little effect on the roll terms, as well as the stick
excitation having little effect on the yaw terms, due to the poor relationships between the
signals.
18
Figure 4.4 Coherence of roll and yaw characteristics to lateral Stick input
Figure 4.5 Coherence of roll and yaw characteristics to pedal input
19
4.4 Noise reduction
Selecting the data for using within the system identification is one of the most
important steps in the analysis. Selecting poor, ’noisy’ data or a data set which does not
contain enough information, will give poor results which may mean the following system
identification process is useless. The final step in data selection is to filter out the ‘noisy’ and
poor data that will affect the final results. This is achieved be using the coherence functions
previously generated. Investigating the plots above, we can identify which frequencies are of
sufficient quality and those which we must neglect from using in the final data selection. The
sampling rate for this experiment was 0.1 Hz.
Control (input)
Response
0 - 7.23 Hz 6.96 – 7.86 Hz
None 0 - 4.71 Hz
Table 4.1 Frequency-response ranges for system identification
In using a low pass notch filter, the frequencies desired can be extracted from the
original data without any delay occurring. This delay would have occurred if the responses
had been passed through a standard data filter to remove the unwanted frequencies. The
frequency ranges selected, shown in table 4.1, are generated from the coherence plots and
give good results that effectively reduce the ‘noise’ of the responses. The previous data was
then “filtered” using these frequencies and the resultant plots are shown in figures 4.6 and 4.7.
This was executed by designing a low pass notch filter in MATLAB, using the function
filtfilt. This function transforms the data into frequency domain, extracts the desired
frequencies and then expels those data ranges as time-domain data.
20
Figure 4.6 Pedal input data as a result of frequency filtering
Figure 4.7 Lateral stick input data as a result of frequency filtering
Due to the removal of the frequencies, a side-effect is that the amplitude of the signal
reduces. This is a cause for concern in the evaluation of this data and it remains to be seen
what effect this has on the final results. With the amplitudes of the respective signals already
quite small, it was not ideal to reduce them further. An improved flight test could take into
account this reduction of amplitude by increasing the motion of the aircraft. It should also be
noted that there is a much larger external input from the opposing control device in the stick
input data compared with the pedal input data, this could also have an effect on the final
results.
21
These two data sets will be used to estimate two models of this aircraft using each set
of data: a pedal input and a lateral stick input. Each will be used to generate a full model
before the optimum parameters from both are selected to generate a single model. This is
done due to the fact that both separate inputs generate very dissimilar flight characteristics
which are required to be modelled.
4.5 Constructing Initial Parameter Estimates
Due to the data being taken from the same aircraft as used in [17] we can use the
parameters generated through the same similar experiments in the system identification
analysis as initiation parameters in a bid to increase the chances of obtaining more accurate
results. Owing to the possibilities that the aircraft may have been changed in control
configuration for this flight as compared to the previous research, it was determined that it
was suitable to use only the previous stability derivative parameters as initial estimates and
evaluating totally new control derivatives. The initial parameter values used to generate the
two system models are shown in table 4.2.
Parameter Lateral stick-response
model
Rudder pedal input
model
0.148 -0.046
0.047 -0.001
-2.407 -1.144
0.039 0.039
-0.426 -0.939
Table 4.2 Initial estimates for stability derivatives
4.6 Implementation of equations
The differential equations (equation 3.8) were implemented with the aid of the
MATLAB System Identification Toolbox. This toolbox is designed to aid the user in the
construction of mathematical models from measured input-output data. The toolbox can
22
utilize both frequency and time domains, create various types of models and has a number of
available identification techniques available.
Initially, a model of the differential equations had to be established. This was
completed using a .MEX function which provides an interface between MATLAB and
subroutines. This function can be written in C, C++ or Fortran and by using an external code
to write important subroutines, the processing time for the code can be accelerated. With
MATLAB’s convenient structure and interface combined with C++’s speed, the coding
structure will be optimized for a speedy processing time.
The internal MATLAB function IDNLGREY was used to evaluate the model of the
differential equations. Essentially, this function uses the equations compiled in the .MEX
function that creates a grey-box model which can be used in the identification process. Initial
estimates of the parameters and all other initial states are stored into this model along with the
input-output data. This model is then used by the identification method to evaluate all of the
parameters that have been specified. Parameters can be fixed and changed easily, allowing
known and erroneous data to be altered to aid in the identification process. It is imperative to
create the model exactly as needed, with the correct data passed in and out.
Some attempts made to establish this particular model encountered some issues with
parameter definitions along with ensuring the correct data was being passed and taken from
the precise points within the code. Difficulty was also encountered when implementing
the .MEX function as the user had no previous experience of C++ programming.
Full code can be found in the Appendix.
23
5. Prediction Methods
System identification is essentially a type of system approximation where we attempt
to find a model that is within an acceptable accuracy. Two main parameter estimation
techniques are available within MATLAB for evaluating parameterized grey-box models; a
prediction error method and subspace methods for use with estimating state-space models.
5.1 Prediction Error Methods
The most common and general approach to estimating the parameters is the
predication error method (PEM)[14], where the parameters within the model are selected to
minimize the error that is accrued between the predicted output of the model and the actual
output. This estimation involves a numerical search for the best fit of the solution using an
iterative process.
As an example of this process consider the following SISO Output-Error model
structure[20]:
Equation 5.1
The basic idea behind the prediction error approach is simple. When the deterministic
part of equation 5.1 is stable, the prediction for the model can be written in the following
simpler form:
Equation 5.2
With the predication error given as:
Equation 5.3
Where describes the model as a predictor of the next output, i.e. it is a one-step
ahead prediction of the output[21]. For the real model it then holds that the prediction errors
are equal to the true model errors:
Equation 5.4
24
This property emphasises the consistency properties of the PEM and indicates the
close relationship between this method and the maximum likelihood method, which itself
attempts to select the solution with the greatest accuracy.
Prediction Error Methods are a family of parameter estimation methods that can be
applied to various model parameterization setups, this being one of its main advantages along
with having a great relationship to the maximum likelihood method. These methods are
asymptotically minimum variance, asymptotically normally distributed and asymptotically
unbiased (i.e as ) which makes for a good estimation method[22]. PEM
can also operate well with closed loop systems without the need for any special techniques
that need applied, although an explicitly parameterized model is needed for the estimation
process, which can be of difficulty if the system is of a totally unknown structure. Another
drawback to PEM is that the estimation can be laborious and at times the best option may not
be found if many local minima are involved.
5.2 Subspace Methods
Subspace identification can be viewed as a more perceptive method than PEM as it
uses projection matrices to extract the unknown parameters instead of an iterative method.
The process contains numerous steps, but is still more computationally efficient than
compared to an iterative method which is particularly useful for MIMO systems due to their
large data sets. A full description of this method can be found in [23].
5.3 Prediction Method Evaluation
In comparing various system identification cases which use both PEM and subspace
methods as predictor in [23], it was deemed that subspace methods present a valid alternative
to conventional PEM. Although PEM is still the favoured choice for identification, subspace
methods are faster and sufficiently accurate with prediction error methods still being
considered more precise. Since the data range in our investigation will be relatively small, the
speediness of the evaluation technique was not considered a priority. It is however worth
noting, that subspace methods are a very important tool in gaining an initial estimate of the
model parameters, as they generate values that are weighted against the output and so will
25
have some correlation to the desired solution. It was concluded that the identification method
should use both of these procedures.
5.4 Implementation
After investigation of the available MATLAB tools, an algorithm was found to fit our
needs exactly. The system identification function pem uses a subspace function n4sid to
first identify the initial estimates of the system. As acknowledged through the function name,
pem then uses a prediction error method to evaluate the model properties and generate a
result that is of minimum calculation error.
26
6. Results
The final results were generated using the above procedures and the results follow.
6.1 Pedal-response model
The simulated pedal-response, as generated by the resultant pedal-response model is
compared against the time-domain data which was used to generate the model (figure 6.1).
The comparison shows an acceptable fit for all expected parameters, such as good
yaw motions (lateral velocity and yaw rate) and poorer roll motions (roll rate and roll angle).
Figure 6.1 Initial verification of pedal-response model
This comparison is of directly related data, being that the comparison data in this case
was used to generate the model. This type of comparison can make the model appear
respectable but may be hiding major errors in the process.
The prime method of model quality verification is to reproduce the behaviour of fresh
responses that was never used in the identification process; this new data is known as
validation data. We therefore simulate the model using this further data, which was collected
using the same aircraft and can either visually check or use a numerical measurement to
decide if the fit is good enough for the model.
Data from a subsequent experiment was used to minimize external effects that any re-
configuration of the aircraft and re-fuelling could have on the system dynamics, hoping that
the only change in the experiment would be the input stimulus. The flight data chosen for
27
validation data was an experiment with primarily lateral motions but at a higher flight speed
and using frequency sweep type input. This will ensure a very robust validation test. The
result of this new comparison is shown in figure 6.2 and uses the same identified model as
generated by the data in figure 6.1.
Figure 6.2 Verification of pedal-response model with validation data
In examination of the new comparison, it can be seen that the same parameters as
before (lateral velocity and yaw rate) are the better modelled signal out of the four outputs.
This gives us confidence that the yawing motions were modelled with some accuracy, with
particularly the lateral velocity, , having a very good fit. The yaw rate response was not as
good, but it still had a relatively good comparison to the flight data to which gave us
confidence that it at least some of the model governing this output has been modelled
correctly. The roll rate and roll angle parts of the modelled can be discarded as they do not
sufficiently model the flight data motions in both verification. The model generated seems to
consistent for the pedal-response reliant signals.
6.2 Stick-response model
The stick-response model was the next to be examined. The simulated response, as
generated from the stick-response derived model, is compared against the time-domain data
that was used to generate the model (figure 6.3).
28
The same process follows that previously outlined above. We notice immediately that
this model generates inferior responses as compared to the pedal-response model. As before,
the lateral velocity component has a good match but the other three outputs only follow
slightly the course of the flight test data. The most notable aspect is the roll responses of this
analysis which we would have expected to be of respectable comparisons are extremely poor.
Figure 6.3 Initial verification of stick input
Due to this model’s results, it was not able to be compared against any validation data
- the model would not work with the frequency sweep data. It can be then said that the model
response for the lateral stick perturbation does not contain a high enough accuracy to be used
with confidence. The results of the identified parameters will still be used as a comparison to
the identified parameters from the pedal-response model but will not form the basis of any
final solution.
The main contributing factor for creating two separate input models was to model all
of the responses with respect to their main excitation input. What would have been expected
is a fairly accurate roll rate and roll angle response to a lateral stick input.
6.3 The side force derivatives
From the results of the identification process, the values of all stated derivative are
output from the finalised models. The side force derivatives generated from both models can
be seen in table 6.1.
29
The side force derivatives are extracted from the lateral velocity signal response. With
a sufficiently good model fit and validation fit of the sideslip signal by the pedal-response
model, the side force stability derivatives will be taken from this model. Furthermore it was
previously foreseen that these derivatives would originate from this input-response excitation
and so further validates our choice.
Parameter Lateral stick input Rudder pedal input
2.13793 (0.0349081) 0.878698 (0.104095)
-0.097739 (0.0117373) 0.0456625 (0.00493327)
Table 6.1 Sideforce derivatives
Naturally these results may also be full of errors from the prediction method and we
always have to be careful of this in system identification. One method used to investigate the
confidence of these values is to investigate the standard deviation - which is shown in
brackets adjacent to the stability derivative values. With both of the denoted side force
stability derivatives having relatively small standard deviations we can then tentatively accept
them as the acceptable values.
6.4 The rolling moment derivatives
The rolling moment derivatives are generated from the roll rate signal part of the
model, and are shown in table 6.2.
Parameter Lateral stick input Rudder pedal input
0.0426948 (0.00237575) 0.00208104 (0.000193996)
-0.482931 (0.0524439) -0.0669935 (0.0104679)
0.00225471 (0.000501164) -0.00146285 (0.000151123)
0.0154083 (0.00104065) 0.00060241 (0.000067944)
Table 6.2 Rolling moment derivatives
30
During the data validation process, it was decided that these results should not be
considered in the final solution due to the roll rate signal in both models being poorly
validated for this response and no confidence in these solutions could be found.
6.5 Yawing moment derivatives
The yawing moment derivatives are generated from the yaw rate signal part of the
model, and are shown in table 6.3.
Parameter Lateral stick input Rudder pedal input
0.132455 (0.00346299) 0.0586699 (0.00525936)
-2.36593 (0.0465943) -1.8769 (0.103587)
-0.000384987 (0.00014805) 0.00775002 (0.000720292)
0.00014856 (0.000515368) 0.0102646 (0.000293754)
Table 6.3 Yawing moment derivatives
With the yaw response signal being reasonably validated in the pedal-response model,
along with the expectation that the pedal input will excite a yawing response, it was decided
that the yawing moment derivatives should be taken from this model. Again after
investigating the standard deviation of the parameters, they were decided to be in sufficiently
accuracy to be accepted as good product of the prediction method.
31
7. Discussion
One of the main issues noted in the previous research of this aircraft was the unstable
spiral mode which originated from a positive value of . It would be ideal to suggest that
this value has been verified and confirmed, as shown in table 6.2, although it is with great
frustration that these rolling moment derivatives cannot be verified with confidence. The
overall aspect of the system identification process has been to use the judgement of the
engineer to maximise the success of the procedure. It can be then a useful task in identifying
which issues have affected the rolling motion simulations to be so poor compared to the yaw
motions of the aircraft.
If the issue was purely a data problem we would at least expected to have a successful
verification of the plot if the model had been crated perfectly and so the main focus has to be
on the equations of motion used within the identifying process (equation 3.8). The fine-line
between model simplification and ensuring that enough information is available to the
identifier is a difficulty. The equation that corresponds with the best fitted and verified plots
is consequently the equation containing the most information. The side force velocity
differential equation was created with a great deal of known information such as and
replacing some known derivatives. With only two unknowns, and , the identification
method was able to focus more fully on identifying these parameters as compared to the
remaining equations which have numerous unknowns.
The exclusion of the pedal input in would have also been a boost to the
identification and the accurate validation plots, as the differential equation would not have
been affected by the small lateral stick perturbations that still exist in the signal. For this type
of work, the desired identification signal would contain purely one input perturbation whose
excitation could be directly related to a specified output with all other input perturbations
remaining small. Both and have both pedal and stick inputs included in their respective
equations, with producing more reliable results. This might allude to the magnitude of each
“unwanted” input, with the yaw rate differential equation containing a much smaller
opposing lateral stick input as compared to the much larger rudder input in the roll rate
equation. The lateral stick response model contains numerous signals that do not correlate
with the input, compared with the pedal response model, such as; a larger opposing input in
the pedal perturbation which produced a lateral velocity of the aircraft which is of similar
magnitude to that produced in the pedal input.
32
Concentrating more on the successfully verified signals, we can say that the yaw and
side force derivatives can be relied upon.
is of great interest, as it appears positive where it is should usually be negative. A
negative value gives a restoring moment to the aircraft when a gust strikes it., the positive
nature therefore suggests poorer flying qualities at low speed. In the previous research of this
aircraft . The result may be erroneous, which seems unlikely due to the best fit
of the signal on the validation signal and the low percentage of error in the standard deviation
investigation. It is more likely to represent that the aircraft has poorer flying qualities at low
speeds, with the derivative having a significantly larger value compared to the higher speed
flights.
33
8. Conclusion
The use of the MATLAB system identification toolbox is primarily used for electrical
and control systems and is not really used for identifying dynamical systems, it may not have
been the best choice of identification tool for this research. The majority of dynamical system
identification research is undertaken using more appropriate tools, such as CIFER© or
specifically designed code, which is designed especially with aircraft MIMO systems in mind
[10].
It has also been well to highlight how much user involvement and judgement needs to
be taken into account and the whole process can take years to master. System identification is
not just a “push-button” type of process, a large understanding of the process and the eventual
goal is needed to produce excellent results.
The research into this topic was extremely interesting and the information, difficulties
and techniques that were learned could be the basis for future, more improved results.
34
Acknowledgements
The author wishes to thank Dr. Stewart Houston for his valued input and access to the past
information on his previous work which acted as a basis for this project. The author would
also like to thank his family and many friends for their continued support over the last six
years at university (and the many places in between) allowing him to veer of the path, which
fundamentally got him back on track.
35
References
[1] Anon, “British Cicil Airworthiness Requirements Sectoin T - Light Gyroplanes,” Civil Aviation
Authority, Paper No. T 860, no. 2, 1993.
[2] M. Gevers, “A personal view on the development of system identification,” in Proceedings of
13th IFAC symposium on system identification, Rotterdam, Netherlands, 2003.
[3] K. Astrӧm and T. Bohlin, “Numerival identification of linear dynamic systems for operating
records,” in IFAC on self-adaptive control systems, Teddinton, UK, 1965.
[4] R. Kalman and B. Ho, “Effective construction of linear state-variable models from input-output
functions,” Regelungstechnik, vol. 2, pp. 545-548, 1965.
[5] L. Ljung, “Asymptotic variance expressions for identified black-box transfer function models,”
IEEE Transactions on Automatic Control, Vols. AC-30, pp. 834-844, 1985.
[6] H. Glauret, “A General Theory of the Autogyro,” Reports and Memoranda No.111, pp. 558-593,
1926.
[7] “Autogyro History and Theory,” [Online]. Available: http://www.jefflewis.net/autogyros.html.
[Accessed 8 April 2012].
[8] “History of Gyroplanes,” [Online]. Available:
http://www.cartercopters.com/history_of_gyroplnes.html. [Accessed 8 April 2012].
[9] R. E. Morrow and E. O. Brigham, “The fast Fourier transfrom,” Spectrum, IEEE, vol. 4, no. 12, pp.
63-70, 1967.
[10] R. Remple and M. B. Tischler, Aircraft and Rotorcraft System Identificaiton: Engineering
Methods with Flight Test Examples, AIAA, 2006.
[11] M. Enqvist, Linear Models of Nonlinear Systems, 2005: PhD thesis, Linköping University,
Linköping, Sweden.
[12] P. Li, I. Postlethwaite and M. Turner, “Subspace-based System Identification for Helicopter
Dynamic Modelling,” in American Helicopter Society 63rd Annual Forum, Virginia Beach, VA,
USA, 2007.
[13] “Selecting a Model Structure in the System Identification Process,” National Instruments, 2010.
[14] L. Ljung, System Identification Toolbox: For Use with MATLAB, User's Guide, The Mathworks,
Inc., 1988.
36
[15] S. M. Ahmad, A. J. Chipperfield and M. O. Tokhi, “Parametric modelling and dynamic
characterization of a two-degree-of-freedom twin-rotot muli-input muti-output system,”
Proceedings of the Institution of Mechanical Engineers Part G, vol. 215, no. 2, pp. 63-78, 2001.
[16] D. G. Thomson, Flight Dynamics 4 course notes, University of Glasgow, Glasgow: unpublished,
2011.
[17] S. S. Houston, “Identificaiton of Gyroplane Lateral/Directional Stability and Control Chraceristics
from Flight Test,” Proceedings of the Institution of Mechanical Engineers, vol. 212, no. G4, pp.
271-285, 1998.
[18] B. Mettler, T. Kanade and M. B. Tischler, “System Identification of Small-Size Unmanned
Helicopter Dynamics,” in Smerican Helicopter Society 55th Forum, Montreal, Canada, 1999.
[19] Y. Zhu, Mulivariable System Identification, Elsevier Science Ltd, 2001.
[20] H. Hjalmarsson and U. Forssell, “Maximum Likelihood Estimation of Models with Unstable
Dynamics and Non-minimum Phase Noise Zeros,” in Poceedings of 14th IFAC World Congress,
1999.
[21] L. Ljung, “Prediction eoor estimation methods,” Circuits Systems and Signal Processing, vol. 21,
no. 1, pp. 11-21, 2002.
[22] M. Lindberg and C. Hunter, Population Dynamics of Vertebrates class notes, Alaska, USA:
Institute of Arctic Biology, 2011.
[23] W. Favoreel, B. De Moor and P. Van Overschee, “Subspace State Space System Identification for
Industrial Processes,” Journal of Process Control, vol. 10, pp. 149-155, 2000.
[24] D. G. Thomson and S. S. Houston, “Advances in understanding autogyro flight dynamics,” in
64th American Helicopter Society Annual Forum, Montreal, Canada, 2008.
i
APPENDIX
i
The Code
The code is generated using MATLAB. The data is stored in the array ‘prepared’. This data
has already been concatenated and has had drop-outs/spikes/trends removed.
The code files are attached and are executed in the following order:
FILTER.m
GYRO.m
The identification process is then executed by the following line:
nlgr = pem(nlgr, z, 'Display', 'On', 'MaxIter', 200)
The parameter values can then be extracted by the line:
Present(nlgr)
Comparison of the data signals is done by:
Compare(z,nlgr)
ii
FILTER.m
% this code generates a signal with "noise" removed via a lowpass notch % filter designed using the function filtfilt. The pre-filtered data is
% extracted from the data set ‘prepared’
% Separate runs must be undertaken for each input. This particular file is
% used to generate the Stick-response input filtered data
close all clear all load Prepared %loads data that has had dropouts deleted and trends removed
% The data is loaded and the frequency limits (in normalized form) that
were taken from examination of the coherence plots
% for STICK DATA InputD = StickData9d; MinFreq = 0.0000001; % normalized frequency range min MaxFreq = 0.2301; % normalized frequency range max
% for PEDAL DATA % InputD = PedalData9d; % MinFreq = 0.0000001; % normalized frequency range min % MaxFreq = 0.15; % normalized frequency range max
% coherence >0.6 - coherence limit
% Plot of the coherence against normalised frequency figure, mscohere(InputD.inputData(:,1) ,InputD.outputData(:,2)), hold on % Roll
rate mscohere(InputD.inputData(:,1) ,InputD.outputData(:,3)), hold on % yaw
rate title('MSCOHERE STICK DATA')
figure, mscohere(InputD.inputData(:,2) ,InputD.outputData(:,2)), hold on mscohere(InputD.inputData(:,2) ,InputD.outputData(:,3)), hold on title('MSCOHERE PEDAL DATA')
% Prepare the data for "filtereing" InputDf = [InputD.outputData(:,1) InputD.outputData(:,2)
InputD.outputData(:,3) InputD.outputData(:,4) ... InputD.inputData(:,1) InputD.inputData(:,2)];
% Filter Design d = fdesign.lowpass('N,Fp,Fst',5,MinFreq,MaxFreq); Hd = design(d); output = filtfilt(Hd.Numerator,1,InputDf);
% Updating a new variable with the "filtered" data StickData9df = iddata([output(:,1) output(:,2) output(:,3) output(:,4)],
[output(:,5) output(:,6)], 0.1);
iii
% Plot the new "filtered" data on the same graph of the "pre-filtered"
figure('name','Output Data','numbertitle','off') subplot(6,1,1) plot(InputD .SamplingInstants,InputD.inputData(:,1),'-.'), hold on plot(InputD .SamplingInstants,output(:,5)) ylabel('Lateral Stick (%)')
subplot(6,1,2) plot(InputD .SamplingInstants,InputD.inputData(:,2),'-.'), hold on plot(InputD .SamplingInstants,output(:,6)) ylabel('Pedal (%)')
subplot(6,1,3) plot(InputD .SamplingInstants, InputD.outputData(:,1),'-.'), hold on plot(InputD .SamplingInstants,output(:,1)) ylabel('v (m/s)')
subplot(6,1,4) plot(InputD .SamplingInstants,InputD.outputData(:,2),'-.'), hold on plot(InputD .SamplingInstants,output(:,2)) ylabel('p (rad/s)')
subplot(6,1,5) plot(InputD .SamplingInstants,InputD.outputData(:,3),'-.'), hold on plot(InputD .SamplingInstants,output(:,3)) ylabel('r (rad/s)')
subplot(6,1,6) plot(InputD .SamplingInstants,InputD.outputData(:,4),'-.'), hold on plot(InputD .SamplingInstants,output(:,4)) ylabel('\phi (rad)')
xlabel('time (s)')
iv
GYRO.m
% this code generates an identification model ‘nlgr’ that will be used in
the
% identification process. The file transfer inputs, initial parameters etc
% into the .MEX file ‘kenyth_c’ which contains the differential E.O.M.
% z = StickData9df; z = PedalData9df ; %initialise data with PedalDatad - which has already had
trends removed and in iddata form
set(z, 'InputName', {'Stick Position' 'Pedal Position'}, ... 'InputUnit', { '%' '%'}); set(z, 'OutputName', {'v' 'p' ... 'r' '\phi'}, ... 'OutputUnit', { 'm/s' 'rad/s' 'rad/s' 'rad'});
%% The input data is shown in a figure
figure('Name', [z.Name ': input data']); for i = 1:z.Nu subplot(z.Nu/2, 2, i); plot(z(:, [], i)); title(['Input #' num2str(i) ': ' z.InputName{i}]); xlabel(''); axis('tight'); if (i > z.Nu-2) xlabel([z.Domain ' (' z.TimeUnit ')']); end end
%% The output data is shown in another figure.
figure('Name', [z.Name ': output data']); for i = 1:z.Ny subplot(z.Ny, 1, i); plot(z(:, i, [])); title(['Output #' num2str(i) ': ' z.OutputName{i}]); xlabel(''); axis('tight'); end xlabel([z.Domain ' (' z.TimeUnit ')']);
Parameters = struct('Name', {'Aerodynamic Lateral/directional derivatives'
'Trim speed' 'Gravity'}, ... % C, 15-by-1 vector. 'Unit', {['-, -, -, -, ' ... '-, -, -, -, ' ... '-, -, -, -, ' ... '-, -, -'] '-' '-'}, ... 'Value', {[-0.046; -0.001; -1.144; 0; 0.039; 0; -0.939; 0;0;0;0;0] 55 -
9.81}, ... 'Minimum', {-Inf(12, 1) -Inf -Inf}, ... % Ignore constraints. 'Maximum', {Inf(12, 1) Inf Inf}, ... % Ignore constraints. 'Fixed', {[false false false true false true false false false false
false false] true true});
% We define the 5 states of the model structure: InitialStates = struct('Name', {'lateral velocity' ...
v
'Roll rate' ... 'Yaw rate' ... 'Roll angle'}, ... 'Unit', {'m/s' 'rad/s' 'rad/s' 'rad'}, ... 'Value', {0 0 0 0}, ... 'Minimum', {-Inf -Inf -Inf -Inf}, ... % Ignore constraints. 'Maximum', {Inf Inf Inf Inf}, ... % Ignore constraints. 'Fixed', {false false false false});
% The model file along with order, parameter and initial states data are % now used to create an IDNLGREY object describing the dynamic system: FileName = 'kenyth_c'; % File describing the model
structure. Order = [4 2 4]; % Model orders [ny nu nx]. Ts = 0; % Time-continuous system. nlgr = idnlgrey(FileName, Order, Parameters, InitialStates, Ts, ... 'Name', 'kenyth_c', 'TimeUnit', 's');
% The input and output signals of the dynamic system are next specified by % simply copying the corresponding bookkeeping data from the IDDATA object: set(nlgr, 'InputName', z.InputName, 'InputUnit', z.InputUnit); set(nlgr, 'OutputName', z.OutputName, 'OutputUnit', z.OutputUnit);
vi
Kenyth_c.MEX
/* Include libraries. */ #include "mex.h" #include <math.h>
/* Specify the number of outputs here. */ #define NY 4
/* State equations. */ void compute_dx(double *dx, double *x, double *u, double **p) { /* Retrieve model parameters. */ double *C, *S, *g; C = p[0]; /* Aerodynamic Lateral/directional derivatives. */ S = p[1]; /* Trim speed. */ g = p[2]; /* gravity. */
/* x[0]: lateral velocity. */ /* x[1]: Roll rate. */ /* x[2]: Yaw rate. */ /* x[3]: Roll angle. */ dx[0]=C[0]*x[0]+(-S[0])*x[2]+g[0]*x[3]+C[7]*u[1]; dx[1]=C[1]*x[0]+C[2]*x[1]+C[3]*x[2]+C[8]*u[0]+C[9]*u[1]; dx[2]=C[4]*x[0]+C[5]*x[1]+C[6]*x[2]+C[11]*u[1]+C[10]*u[0]; dx[3]=x[1]; }
/* Output equations. */ void compute_y(double *y, double *x, double *u, double **p) { /* Retrieve model parameters. */ /*double *C, *S, *g;*/ /*C = p[0]; */ /* Aerodynamic Lateral/directional derivatives. */ /*S = p[1]; */ /* Trim speed. */ /*g = p[2];*/ /* gravity. */
/* x[0]: lateral velocity. */ /* x[1]: Roll rate. */ /* x[2]: Yaw rate. */ /* x[3]: Roll angle. */ y[0] = x[0]; y[1] = x[1]; y[2] = x[2]; y[3] = x[3]; }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* Declaration of input and output arguments. */ double *x, *u, **p, *dx, *y, *t;
vii
int i, np, nu, nx; const mxArray *auxvar = NULL; /* Cell array of additional data. */
if (nrhs < 3) { mexErrMsgIdAndTxt("IDNLGREY:ODE_FILE:InvalidSyntax", "At least 3 inputs expected (t, u, x)."); }
/* Determine if auxiliary variables were passed as last input. */ if ((nrhs > 3) && (mxIsCell(prhs[nrhs-1]))) { /* Auxiliary variables were passed as input. */ auxvar = prhs[nrhs-1]; np = nrhs - 4; /* Number of parameters (could be 0). */ } else { /* Auxiliary variables were not passed. */ np = nrhs - 3; /* Number of parameters. */ }
/* Determine number of inputs and states. */ nx = mxGetNumberOfElements(prhs[1]); /* Number of states. */ nu = mxGetNumberOfElements(prhs[2]); /* Number of inputs. */
/* Obtain double data pointers from mxArrays. */ t = mxGetPr(prhs[0]); /* Current time value (scalar). */ x = mxGetPr(prhs[1]); /* States at time t. */ u = mxGetPr(prhs[2]); /* Inputs at time t. */
p = mxCalloc(np, sizeof(double*)); for (i = 0; i < np; i++) { p[i] = mxGetPr(prhs[3+i]); /* Parameter arrays. */ }
/* Create matrix for the return arguments. */ plhs[0] = mxCreateDoubleMatrix(nx, 1, mxREAL); plhs[1] = mxCreateDoubleMatrix(NY, 1, mxREAL); dx = mxGetPr(plhs[0]); /* State derivative values. */ y = mxGetPr(plhs[1]); /* Output values. */
/* Call the state and output update functions.
/* Call function for state derivative update. */ compute_dx(dx, x, u, p);
/* Call function for output update. */ compute_y(y, x, u, p);
/* Clean up. */ mxFree(p); }
viii
Declaration of Originality Form
This form must be completed and signed and submitted with all assignments.
Please complete the information below (using BLOCK CAPITALS).
Name
Student Number
Course Name
Assignment Number/Name
An extract from the University’s Statement on Plagiarism is provided overleaf. Please read carefully THEN read and sign the declaration below.
I confirm that this assignment is my own work and that I have:
Read and understood the guidance on plagiarism in the Undergraduate Handbook, including the University of Glasgow Statement on Plagiarism
Clearly referenced, in both the text and the bibliography or references, all sources used in the work
Fully referenced (including page numbers) and used inverted commas for all text quoted from books, journals, web etc. (Please check the section on referencing in the ‘Guide to Writing Essays & Reports’ appendix of the Graduate School Research Training Programme handbook.)
Provided the sources for all tables, figures, data etc. that are not my own work
Not made use of the work of any other student(s) past or present without acknowledgement. This includes any of my own work, that has been previously, or concurrently, submitted for assessment, either at this or any other educational institution, including school (see overleaf at 31.2)
Not sought or used the services of any professional agencies to produce this work
In addition, I understand that any false claim in respect of this work will result in disciplinary action in accordance with University regulations
DECLARATION:
I am aware of and understand the University’s policy on plagiarism and I certify that this assignment is my own work, except where indicated by referencing, and that I have followed the good academic practices noted above
Signed