Lecture 1
Lecture 1
Anke Scherb
2
Technische Universitt Mnchen
Lecture - contents
Exercises - contents
3
Technische Universitt Mnchen
Groups of 2 students
Supervised by a tutor
Duration of project work: 6 weeks
Students must hand in a MATLAB code and a written report
Attendance of 3 out of 4 tutorials is required for participation
4
Technische Universitt Mnchen
Literature
Lecture Notes in Engineering Risk Analysis Lecture Notes in Engineering Risk Analysis
Part B Elementary Data Analysis Part Z Annex MATLAB
Prof. Dr. Daniel Straub Prof. Dr. Daniel Straub
TU Mnchen TU Mnchen
http://www.mathworks.de/help/techdoc/
5
Technische Universitt Mnchen
Introduction to MATLAB
Proprietary software
6
Technische Universitt Mnchen
Introduction to MATLAB
Advantages
Intuitive and easy to learn
Fast on matrix operations
Powerful syntax and great function library
Good plotting options
Easy debugging
Additional toolboxes with functions for specific purposes
Disadvantages
Interpreted language, no compiling
Not designed for word processing, internet applications, GUIs
Costs: commerically available
7
Technische Universitt Mnchen
Editor Editing
Workspace Collects
MATLAB programs
saved data
Current directory
Provides access to files
8
Technische Universitt Mnchen
=> Example.calculator
9
Technische Universitt Mnchen
1 clc h
2 clear all
3
4 % Input dimensions of beam in cm
5 b = 25; b
6 h = 40;
7
8 % Compute moment of inertia in cm^4
9 Iy = b*h^3;
10 Iy = Iy/12;
10
Technische Universitt Mnchen
11
Technische Universitt Mnchen
12
Technische Universitt Mnchen
13
Technische Universitt Mnchen
1 clc h
2 clear all
3
4 % Input dimensions of beamSuppresses
in cm screen
5 b = 25; printing b
6 h = 40;
7
8 % Compute moment of inertia in cm^4
9 Iy = b*h^3;
10 Iy = Iy/12;
14
Technische Universitt Mnchen
Basic commands
Continuous a line
15
Technische Universitt Mnchen
Vectors
v = [3 1 7 -21];
v = [3;1;7;-21];
16
Technische Universitt Mnchen
Vectors
17
Technische Universitt Mnchen
Vectors
18
Technische Universitt Mnchen
Vectors
v(1)
u(3)
w = v(1:2:4); % vector elements 1 to 4 with increments of 2
Vector functions
Example: Vectors.m
19
Technische Universitt Mnchen
Matrices
20
Technische Universitt Mnchen
Matrices
A =
1 2 3
4 5 6
7 8 9
21
Technische Universitt Mnchen
Matrices
22
Technische Universitt Mnchen
Matrices
23
Technische Universitt Mnchen
Matrices
24
Technische Universitt Mnchen
Matrices
A.*B
A./B
A.^B
25
Technische Universitt Mnchen
Matrices
Math functions of matrices Return matrices of same size with each entry
specified by performing the operation at the corresponding entry of the original
matrix
sin(A)
log(A)
Example: Matrices.m
26
Technische Universitt Mnchen
Matrices
27
Technische Universitt Mnchen
Matrices
28
Technische Universitt Mnchen
Matrices
29
Technische Universitt Mnchen
Matrices
30
Technische Universitt Mnchen
31
Technische Universitt Mnchen
All of the pre-built commands that you use in MATLAB are script files or
functions (plot, mean, std, exp, cosd, )
MATLAB allows the user to create his/her own customized m-files for
specific applications or problems.
Save the file in an appropriate folder. When you pick a name for the file
you must follow the same rules that MATLAB has for naming variables.
Set the current directory in MATLAB to the same place where you saved
the script file.
To run the script file: Hit the Green Run Arrow in the Editor window
Example: CircleScript.m 32
Technische Universitt Mnchen
All natural and human processes are subject to variability of some kind
=> hence there is most often uncertainty to some extent
33
Technische Universitt Mnchen
Example: Tensile strength and Youngs modulus from tests on timber specimens
(provided by Lehrstuhl fr Holzbau und Baukonstruktion, TUM).
34
Technische Universitt Mnchen
Sample range Interval between the lowest and the largest value of the data set
range(data)
Note: The sample mean is sensitive to outliners (unexpectedly low or high values)
35
Technische Universitt Mnchen
Sample median The value for which there is an equal number of larger and
smaller samples
median(data)
36
Technische Universitt Mnchen
Sample variance Mean of the square of differences between the samples and
the sample mean
1 n
i
2
s
2
x x
n 1 i 1
var(data)
37
Technische Universitt Mnchen
std(data)
38
Technische Universitt Mnchen
Sample quantiles Values that separate the ordered samples into k groups of
equal number of samples. E.g. quartiles divide the samples into four groups of
n/4 samples.
Sample percentiles Values below which a certain percentage of all samples lie.
E.g. the 10-percentile x10 is the value below which 10% of samples lie
quantile(data,p)
prctile(data,p)
39