matlab toolboxes
DESCRIPTION
This document describes about Matlab toolbox. It will help to understand the use of toolbox.TRANSCRIPT
-
Virginia Polytechnic Institute and State University
1 of 31
Introduction to MATLAB
MATLAB Toolboxes
Computer Applications in CEE
Drs. Trani and Rakha
Civil and Environmental EngineeringVirginia Polytechnic Institute and State University
Spring 2000
-
Virginia Polytechnic Institute and State University
2 of 31
Sample Toolboxes
MATLAB has been extended over the years to respond to the needs of various users
Several toolboxes exist to add to the power of the original language. For example:
- Simulink - Fuzzy Logic- Neural Networks- Optimization- Controls- C/C++ compiler library- Real-time workshop
-
Virginia Polytechnic Institute and State University
3 of 31
Simulink
Simulink is a powerful toolbox to solve systems of differential equations
Simulink has applications in Systems Theory, Control, Economics, Transportation, etc.
The Simulink approach is to represent systems of ODE using block diagram nomenclature
Simulink provides seamless integration with MATLAB. In fact, Simulink can call any MATLAB function
Simulink interfaces with other MATLAB toolboxes such as Neural Network, Fuzy Logic, and Optimization routines
-
Virginia Polytechnic Institute and State University
4 of 31
Simulink Building Blocks
Simulink has a series of libraries to construct models
Libraries have object blocks that encapsulate code and behaviors
Connectors between blocks establish causality and flow of information in the model
-
Virginia Polytechnic Institute and State University
5 of 31
Simulink Interface
The main application of Simulink is to model continuous systems
Perhaps systems that can be described using ordinary differential equations
-
Virginia Polytechnic Institute and State University
6 of 31
Typical Simulink Libraries
Shown are some typical Simulink libraries (Macintosh)
-
Virginia Polytechnic Institute and State University
7 of 31
Sample Simulink Library (Windows and UNIX)
The new Simulink interface in Windows/UNIX uses standard OOP interfaces (Visual C++, Visual Basic)
-
Virginia Polytechnic Institute and State University
8 of 31
Simulink Example
The following example illustrates the use of Simulink to solve a two vehicle car-following problem. This problem has been studied for the past 40 years in traffic flow theory
where: is a gain constant of the response process
is the acceleration of the following vehicle
is the speed of the leading vehicle
is the speed of the following vehicle
x t +( ) fc k x t( ) lc x t( ) fc( )=k
x t +( ) fcx t( ) lcx t( ) fc
-
Virginia Polytechnic Institute and State University
9 of 31
Set-Up of the Problem
Assume the velocity profile of the leading vehicle is known (we drive this car to test the response of the following vehicle)
Initially, assume no time lags in the acceleration response of the following vehicle ( )
Test an emergency braking maneuver executed by the first vehicle at 3 m/s
2
Test a new scenario with a deterministic time lag response time of 0.75 seconds
Verify that both cars do not collide
0=
-
Virginia Polytechnic Institute and State University
10 of 31
Simulink Representation of the Car-Following Problem
X
Car Following Problem
Xdot
k (Xdot_ltu - Xdot_ftu)Xdot_ltu - Xdot_ftu
Speed Profiles
Speed LTU
Mux
Mux1
Mux
Mux
s
1
Integrator2
s
1
Integrator1s
1
IntegratorDistance Profiles
2
Constant
-
Virginia Polytechnic Institute and State University
11 of 31
Car-Following Model Output
Velocity profiles for leading and trailing vehicles
Time (s)
Speed (m/s)
-
Virginia Polytechnic Institute and State University
12 of 31
Car-Following Model Output
The time space diagram below illustrates an emergency braking maneuver for the leading vehicle
Time (s)
Space (m)
-
Virginia Polytechnic Institute and State University
13 of 31
Car-Following Model with Delay
A pure transport delay block is added to the original model simulating the transport lag dynamics of a man-machine system
X
Xdot
k (Xdot_ltu - Xdot_ftu)Xdot_ltu - Xdot_ftu
TransportDelay
Speed Profiles
Speed LTU
Mux
Mux1
Mux
Mux
s
1
Integrator2
s
1
Integrator1s
1
IntegratorDistance Profiles
1Constant
-
Virginia Polytechnic Institute and State University
14 of 31
Output of the Car-Following Model with Delay
The output suggests that a collision occurs with =0.75s.
Time (s)
Space (m)
-
Virginia Polytechnic Institute and State University 15 of 31
Brief on C/C++ Compiler
Converts MATLAB M-Files to C and C++ code Using this toolbox all graphics and math code can be
converted to develop standalone applications Typically requires MATLAB compiler and the MATLAB
C/C++ library New features in version 5.3 also convert cell and
structure arrays
My limited experience with this toolbox suggest substantial gains in speed if no vector operations have been implemented in the code
Vector operations show very little improvement when the code is compiled
-
Virginia Polytechnic Institute and State University 16 of 31
Neural Network Toolbox
Provides 100+ functions to simplify the training, generalization and implementation of artificial neural networks
The functional implementation of the ANN toolbox is just through a series of MATLAB functions
All ANN functions are execued from the command line
P
PRxQ
Input
1
W1
b1
W2
b2
W3
b3
Z1xR
Z1x1
n1
Z1xQ
a1 Z1xQ
Z2xZ1
Z2X1
n2
Z2xQ
, a2
1 1
Z3xZ2
Z3x1
Z2xQ n3
Z3xQ
a3
Z3xQ F2 F3
F1
-
Virginia Polytechnic Institute and State University 17 of 31
Relevant Functions Provided
Layer initialization functions (Nguyen-Widrow) Learning functions (gradients, perceptron, Widrow-Hoff) Analysis functions (max. learning rate, error surface) Line search functions (Golden section, backtraking) Network functions (competitive, feed-forward wth
backpropagation) Performance functions (mean absolute error, SEE) Training functions (BFGS, Bayesion regularization,
Fletchel-Powell, Lavenberg-Marquardt, etc.) Transfer functions (log signmoid, tangent sigmoid, etc.)
-
Virginia Polytechnic Institute and State University 18 of 31
Example of ANN Using MATLAB
Problem:
To estimate aircraft fuel consumption based on aircraft performance parameters
Implementation on fast-time simulation models (SIMMOD, RAMS, etc.)
Solution
Prototype model using MATLABs neural Network Toolbox
Verify the accuracy of the model with the current state-of-the art
-
Virginia Polytechnic Institute and State University 19 of 31
Sample Data Presented in Flight Manual
-
Virginia Polytechnic Institute and State University 20 of 31
Modeling Approach
Data Normalization
Training Data Set
Input learning pairs
Initialize connectionWeights
Learning Module
Import Data
ForwardPropagation
ComputeError
Change and Update weights
ConfigurationParameters
Error< eg
Numberof cycles > me
End of learning
YES
NO
YES
NO
eg - maximum allowable errorme- maximum allowable iterations
-
Virginia Polytechnic Institute and State University 21 of 31
Selected ANN Topology
sum f1
sum f1
sum f1
sum f1
sum f1
sum f1
sum f1
sum f1
sum f2
sum f2
sum f2
sum f2
sum f2
sum f2
sum f2
sum f2
sum f3
Target
Altitude
Mach
InitialWeight
ISA Cond.
w1,11
w 8,4
1
b1 1
a11
a 18
w2
1,1
w2
8,8
n1
1
n1
8
n2
1
b2
1
a2
1
b3
1
n3
1Fuel burn
b2
8
n2
8
a2
8
Where f1 - log-sigmoid transfer function
f2 - tansigmoid transfer function
f3 - purelin transfer function
-
Virginia Polytechnic Institute and State University 22 of 31
ANN Data
The data sets used to develop and train the ANN are shown below. Generalization of the ANN was conducted using another (random) data set
Flight Phase Number of Testing PointsTakeoff and Climbout Nor applicable (linear regres-
sion used instead)Climb to Cruise Altitude 850 (Fuel)
850 (Distance)Cruise 805
Descent 1210 (Fuel)140 (Distance)
-
Virginia Polytechnic Institute and State University 23 of 31
Summary of Results (Fokker F100)
The results shown in the table illustrate the accuracy of the model
Flight PhaseMean
Error (%)Standard
Deviation (%)Null Hypothesis(t-test at )
Climb
Distance
Fuel
0.377 1.026
0.3050.190
AcceptAccept
Cruise Specific Air Range
-0.034 0.334 Accept
0.01=
-
Virginia Polytechnic Institute and State University 24 of 31
Descent
Distance
Fuel
1.7601.423
1.8601.177
AcceptAccept
Flight PhaseMean
Error (%)Standard
Deviation (%)Null Hypothesis(t-test at ) 0.01=
-
Virginia Polytechnic Institute and State University 25 of 31
Sample Results (Climb Fuel)
The results of training an ANN with 3 layers are shown below
0 5 10 15 20 25 30 35 400
1000
2000
3000
4000
5000
6000
Clim
b Fu
el (lb
)
Pressure Altitude (kft)
*Actual DataEstimated Data
-
Virginia Polytechnic Institute and State University 26 of 31
Absolute Error of ANN
The errors of the ANN are very small as depicted in this graph for SFC
-1.5 -1 -0.5 0 0.5 1 1.50
20
40
60
80
100
120
140
160
Frequ
ency
Complete flight envelope
805 data points
0.60 < Mach < 0.7510,000 ft < altitude < 37,000 ft58,000 lb < weight < 98,000 lb
Specific Range Error (%)
-
Virginia Polytechnic Institute and State University 27 of 31
Application of the Model to Complete Flight Plans
The ANN model developed has been applied to a generic flight trajectory generator with very accurate results
8085
9095
100 2626.5
2727.5
2828.5
2929.5
0
10
20
30
Longitude (deg) Latitude (deg)
Alti
tude
(kft)
Flight plan way-points
DFW
MIA
Pseudo-globe circle route
Constant headingsegments
ClimbDescent
-
Virginia Polytechnic Institute and State University 28 of 31
Complete Flight Plan Correlation
FlightCruise Flight Level (FL)
Distance (nm) /
Time (hr)
Flight Manual Fuel Burn
(lb)Neural Net
Fuel Burn (lb)Percent
Difference (%)
ROAa-MDWb
a.ROA - Roanoke Regional Airport (Virginia)b.MDW - Midway Airport (Illinois)
280 448 / 1:08 6,457 6,546 1.37310 448 / 1:10 6,360 6,330 0.46
MIAc-DFWd
c.MIA - Miami International (Florida)d.DFW - Dallas-Forth Worth International (Texas)
310 972 / 2:24 11,851 11,865 0.12350 972 / 2:13 11,510 11,544 0.29
ROA-LGAe
e.LGA - Laguardia Airport (New York)
290 352 / 0:57 5,298 5,260 0.71330 352 / 0:58 5,343 5,429 1.61
ATLf-MIA
f. ATL - Atlanta Hartsfield International Airport (Georgia)
290 518 / 1:20 6,990 7,047 0.80330 518 / 1:21 7,009 7,082 1.04
-
Virginia Polytechnic Institute and State University 29 of 31
Sample Source Code
% Initialize Weights and Biasis
nns = 8; % Number of Neurons in each layernns2 = 8; %********************************% For Climb Distance **%********************************[W31_cb_d,b31_cb_d,W32_cb_d,b32_cb_d,W33_cb_d,
b33_cb_d ]=initff(P1_cbd,nns,'logsig',nns2 ...,'tansig',T1_cbd,'purelin');
% Taining of the neural networks using Lavenberg-Marquardt Alogrithm
-
Virginia Polytechnic Institute and State University 30 of 31
[W31_cb_d,b31_cb_d,W32_cb_d,b32_cb_d,W33_cb_d,b33_cb_d ]= trainlm(W31_cb_d,b31_cb_d,'logsig' ...
,W32_cb_d,b32_cb_d,'tansig',W33_cb_d,b33_cb_d,'purelin',P_cbd,Ta_cbd,tp);
%********************************% For Climb Fuel **%********************************[W31_cb_f,b31_cb_f,W32_cb_f,b32_cb_f,W33_cb_f,b3
3_cb_f ]=initff(P1_cbf,nns,'logsig',nns2,'tansig' ...,T1_cbf,'purelin');
% Taining of the neural networks using Lavenberg-Marquardt Alogrithm
[W31_cb_f,b31_cb_f,W32_cb_f,b32_cb_f,W33_cb_f,b33_cb_f ]= trainlm(W31_cb_f,b31_cb_f,'logsig',W32_cb_f ...
-
Virginia Polytechnic Institute and State University 31 of 31
,b32_cb_f,'tansig',W33_cb_f,b33_cb_f,'purelin',P_cbf,Ta_cbf,tp);