MATLAB Chapter 1: An Overview of MATLAB
MATLAB Chapter 1: An Overview of MATLAB
An Overview of MATLAB
MATLAB
2
Why use MATLAB?
3
Programming with MATLAB
4
MATLAB in University/Industry
5
1.1 Starting Matlab
This window
shows the current
directory or the This is the
workspace command
This window window
shows the
command
history
6
1.1 Entering Commands and Expressions
8
1.1 Variable
ans =
4
>>
9
1.1 Variable
11
Appendix A
12
1.1 Arithmetic operators
- 5 - 4 = 1
See Table 1.1-2 for the
order of precedence. * 5 * 4 = 20
/ 5 / 4 = 1.25
13
1.1 The Assignment Operator
14
Example 1.1-1
Volume of a circular
>> r=8;
cylinder:
>> h=15;
Given radius r and >> V=pi*r^2*h;
height h and volume >> V=V+0.2*V;
V=pi*r^2*h of a cylinder, >> r=sqrt(V/(pi*h))
find radius of another
cylinder with the same r =
height and a volume
8.7636
20% greater.
Notice: Using a semicolon >>
“;” after a command
removes screen printing. Notice that new values
of r and V replace old values
15
1.1 Managing the Work Session
16
1.1 Managing the Work Session
Instead of retyping the entire line, press the up-arrow () and the
down-arrow () to recall previous commands you typed in your
session.
17
1.1 Managing the Work Session
19
1.1 Complex Number Operation
>> s=3+7i;
>> w=5-9i;
>> w+s
Matlab handles complex ans =
number algebra
8.0000 - 2.0000i
automatically. For example
>> w*s
c1= 1-2i (or 1-2*i).
ans =
Caution: You CANNOT 78.0000 + 8.0000i
type 1-i2. >> w/s
ans =
-0.8276 - 1.0690i
>> (-3+7i)*(-3-7i)
ans =
58
20 >>
1.1 Formatting Commands
21
1.2 Menus and the Toolbar
22
1.3 Computing with Matlab Arrays
>> x=[0 1 2 3]
Matlab can handle collections of
numbers, called arrays, as if they x =
were a single variable.
0 1 2 3
>> x=[0,1,2,3]
Possible way to define an array
elements must be separated by a x =
comma or space (or both). 0 1 2 3
>>
Order of elements is important.
23
1.3 Arrays
>> x=2:8
It is not necessary to x =
24
1.3 Array Operations
Simple array operations can be done like matrix operations:
>> x=0:3;
>> y=sin(x)
y =
0 0.8415 0.9093 0.1411 Note: Matlab
>> z=cos(x) trigonometric
functions use
z =
radian measure.
Using degrees can
1.0000 0.5403 -0.4161 -0.9900 be done by hand:
>> y+z cosine 60° is
cos(60*pi/180)
ans =
>>
25
1.3 Arrays
26
1.3 Arrays
>> x=0:3;
>> y=sin(x)
y =
>> z=cos(x)
z =
>> y.^2+z.^2
ans =
>> y^2+z^2
??? Error using ==> mpower
Matrix must be square.
>>
27
1.3 Array Index
28
1.3 Array Index
29
1.3 mxn Arrays
One way to write an mxn array in Matlab, use semicolons “;” to
separate between rows: >> A=[1;3;5]
>> A=[1 2 4 5;5 -3 9 2]
A =
A =
1
1 2 4 5 3
5 -3 9 2 5
1 2 4
30 2 4 5
1.3 Polynomial Roots
ans =
To find the polynomial from its roots, use
the function poly([root1,root2,…]) 1 -7 40 -34
>>
31
1.3 Working with files
32
1.3 MAT-files
33
1.3 MAT-files
You can define your own MAT-file by using
save filename and load filename
The variables are then stored in the file filename.mat
34
1.3 M-files
35
1.3 Directories and Search Path
36
1.3 Directories and Search Path
37
1.3 Directories and Search Path
38
1.3 Plotting with Matlab
>> x=0:0.1:10;
>> y=sin(x);
>> plot(x,y)
39
1.3 Plotting with Matlab
40
1.3 Plotting with Matlab
This Figure1.fig
file can be saved
under a different
name and format
for usage within
other programs
like MS Word.
41
1.3 Plotting with Matlab
Example:
plot(x,y),xlabel(‘time(s)’),ylabel(‘voltage(V)’),title(‘V vs. t’)
42
1.3 Plotting with Matlab
You can create multiple plots by including another set of values in the plot:
plot(x,y1,x,y2,x,y3)
Typing plot(x,y,’+’) will return a scatter plot without a line, where the
data points are represented by a “+” sign.
Solution =
3
5
44 -2
1.3 Statistics
ans = ans =
0 5
ans = ans =
10 3.3166
45
1.4 Script Files and Editor/Debugger
Effective Use ofScript Files
% is used to write
comments (will not be
compiled). Text color in M-
file editor after % is green.
Semicolons “;” can be
used as usual.
Filenames can be typed
directly in the command
window, if their directory is
in the search path.
Writing type filename
in the command editor
displays the file in the See page 31-32 in TB on what to
command window. remember when using script files
46
1.4 Debugging Script files
If due to a certain mistake, you would like to stop the program from
running, press
Ctrl+c
47
1.4 Controlling Input and Output
49
1.6 Programming in Matlab
ans =
>> x='m';
>> y='m';
>> x==y
ans =
>>
51
1.6 Relational Operators
We can compare arrays on an element-by-element basis:
>> x=[6,3,9]; >> A=[1,2,3;4,5,6];
>> y=[14,2,9]; >> B=[1,2,3;5,5,6];
>> z=(x<y) >> A==B
z = ans =
1 0 0 1 1 1
0 1 1
>> z=(x==y)
>> C=A~=B
z =
C =
0 0 1
0 0 0
>> z=x==y %another way to write it 1 0 0
z = >>
0 0 1
52
1.6 Relational Operators
>> x=[2,3,1];
>> y=[1,2,5];
>> x(x>y)
ans =
2 3
>>
53
1.6 Relational Operators
>> x=[1,2,9,0,3,0,3];
>> y=find(x)
y =
Only
1 2 3 5 7 indices are
returned.
54
1.6 Conditional Statements IF-ELSE-ELSEIF
56
1.6 Conditional Statements
57
1.6 Loops
58
1.6 Loops
Syntax:
59
1.6 Programming in Matlab
60
1.6 Loops
for-loop example:
%first method %second method
m=0; m=1;
x(1)=10; x(m)=10;
for k=[2:3:11] for k=2:3:11
m=m+1; x(m+1)=x(m)+k^2;
x(m+1)=x(m)+k^2; m=m+1;
end end
x x
>> x
x =
10 14 39 103 224
61
1.6 Loops
while-loop example:
62
1.6 Example 1.6-2
15 4x 10 if x 9
y(x) 10x 10 if 0 x 9
10
if x 0
63
1.6 Example 1.6-2
15 4x 10 if x 9
y(x) 10x 10 if 0 x 9
10
Plot y(x) vs x for -5x30 if x 0
%Example 1.6-2: using for loop %Example 1.6-2: using while loop
clear clear
dx=35/300; dx=35/300;
x=[-5:dx:30]; x=[-5:dx:30];
k=1;
for k=1:length(x)
if x(k)>=9 while k<=length(x)
y(k)=15*sqrt(4*x(k))+10;
elseif x(k)>=0 if x(k)<0
y(k)=10*x(k)+10; y(k)=10;
else elseif (x(k)>=0)&&(x(k)<9)
y(k)=10; y(k)=10*x(k)+10;
end else
end y(k)=15*sqrt(4*x(k))+10;
plot(x,y),xlabel('x'),ylabel('y') end
k=k+1;
end
64 plot(x,y),xlabel('x'),ylabel('y')
1.6 Example 1.6-3
Compute sum of the 1st 15 terms in the series 5k2-2k, for
k=1,2,…,15
65
1.6 Example 1.6-3
Compute sum of the 1st 15 terms in the series 5k2-2k, for
k=1,2,…,15
%Example 1.6-3: using for loop (TB) %Example 1.6-3: using the sum function
clear clear
total=0; k=1:15;
for k=1:15; y=5*(k.^2)-2*k;
total = 5*(k^2)-2*k + total;
end total2=sum(y)
total %it sums over all ys, i.e y(1)to y(15)
%Example 1.6-3: using for loop %Example 1.6-3: using while loop
clear clear
total1=0; total3=0;
k=1:15; k=1:15;
y=5*(k.^2)-2*k; y=5*(k.^2)-2*k;
67
1.6 Example 1.6-4
Find how many terms it’s required for the sum of the series 5k2-2k,
for k=1,2,…to exceed 10000. What’s the sum of these many terms?
68
1.6 Example 1.6-5
Determine how long it will take to accumulate at least $10000 in a
bank account if you deposit $500 initially and 500$ at the end of
each year, if the account pays 5% annual interest
69
1.6 Example 1.6-5
Determine how long it will take to accumulate at least $10000 in a
bank account if you deposit $500 initially and 500$ at the end of
each year, if the account pays 5% annual interest
%Example 6.1-5
clear
>> Example_1_6_5
amount=500;
years=0;
amount =
while amount<1e4
1.0789e+004
amount=amount*1.05+500;
%or amount=amount+500+amount*0.05
years=years+1;
end years =
amount
years 14
70
MATLAB Chapter 2
Numeric and Matrix Arrays
2.1 Arrays
2
2.1 Arrays
3
2.1 Matrix Transpose
4
2.2 Array Addressing
A=[1 2 3 4; 5 6 7 8; 9 10 11 12];
5
2.2 Array Addressing
Examples:
>> A
v(2:5) represents elements
2 to 5 of vector v A =
1 2 3 4
A(:,3) denotes all elements 5 6 7 8
in column 3 of A 9 10 11 12
>> B=A(2:3,1:3)
A(:,2:4) denotes all elements
B =
in columns 2 to 5 of matrix A
5 6 7
9 10 11
A(2:3,1:3) denotes submatrix
of A with elements in rows 2
to 3 and columns 1 to 3
6
2.2 Other array manipulations
A =
6 9 4 D =
1 5 7
3 8 5
>>B=A(:,end:-1:1) 2 -6 9
B = >> E=D([2,2,2],:)
4 9 6 E =
7 5 1
2 -6 9
2 -6 9
%read matrix A from right to left 2 -6 9
14
2.3 Useful Array Functions
8
2.3 Element by Element Operations
Dimension issue:
Number of A columns SHOULD be equal to number of B rows!!!!!!
ans =
64
75
1
10 20
2.3 Matrix Operations
Matrix multiplication is not commutative:
AB BA
Example:
A=[1 2 3; 4 5 6; 7 8 9];
B=[10 11 12; 13 14 15; 16 17 18];
Result: A*B=[84 90 96; 201 216 231; 318 342 366];
B*A=[138 171 204; 174 216 258; 210 261 312];
11
2.3 Special Matrices
12
2.3 Special Matrices
A^2 = A*A
A^3 =A*A*A
Give Example with A=[1 2 3; 4 5 6; 7 8 9];
13
2.4 Polynomial Operations (Appendix A)
ans =
Example: f(x) = 1x3 7x2 + 40x 34 = 0
1 -7 40 -34
To find the polynomial from its roots, use >>
the function poly([root1,root2,…])
14
2.4 Polynomial Addition and Subtraction
15
2.4 Polynomial Multiplication and Division
The product of the polynomials f(x) and g(x) is
f(x)g(x) = (9x3 – 5x2 +3x +7)(6x2 – x + 2)
= 54x5 – 39x4 + 41x3 + 29x2 – x + 14
>> f=[9,-5,3,7];
>> g=[6,-1,2];
Notice: Unlike >> product=conv(f,g)
during addition or product =
subtraction,
polynomials don’t 54 -39 41 29 -1 14
need to have the
>> [quotient,remainder]=deconv(f,g)
same degree
during quotient =
multiplication or
division (i.e. no 1.5000 -0.5833
need to add
zeros) remainder =
0 0 -0.5833 8.1667
17
2.4 Plotting Polynomials
>> a=[9,-5,3,7];
>> x=0:2:10;
>> f=polyval(a,x);
>> plot(x,f),xlabel('x'),ylabel('f(x)'),grid
18
2.6 Polynomial functions
19
Test Your Understanding
20
MATLAB Chapter 3
Functions and Files
1
3.1 Elementary Mathematical Functions
Appendix A: Common mathematical functions
exp(x) Exponential 𝒆𝒙
log(x) Natural logarithm 𝒍𝒏𝒙
log10(x) Base 10 logarithm 𝒍𝒐𝒈 𝒙
cos(x) Trigonometric cosine in radians
cosd(x) Trigonometric cosine in degrees
atan(x) Inverse tangent in radians
acosh(x) Inverse hyperbolic cosine
2
3.2 User Defined Functions
Function File
3
3.2 User Defined Functions
Function File
The function can be used by typing its name (e.g. drop) at the command
line. The word function in the function definition line must be lowercase.
Before choosing a function name, use the exist function to see if another
Matlab built-in function has the same name.
4
3.2 User Defined Functions
Function File
volume.m
function vol=volume(height,width,length)
vol=height*width*length;
In Command Window
>> V=volume(2,2,3)
no need to use
brackets when having V =
only one variable
12
5
3.2 User defined Function file
Example:
Consider the following parametric equations:
𝒙 𝜽 = 𝒓 𝜽 − 𝒔𝒊𝒏(𝜽)
𝒚 𝜽 = 𝒓 𝟏 − 𝒄𝒐𝒔(𝜽)
Plot the cycloid graph in the command window for the following inputs:
• angle 𝜽 = 𝟎: 𝟎. 𝟎𝟏 ∗ 𝒑𝒊: 𝟔 ∗ 𝝅
• radius 𝐫 = 𝟓.
6
3.2 User defined Function file
function [x,y] = cycloid(theta,r)
%This function calculates the Cartesian coordinates
%x and y from Polar coordinates theta and r for
%cycloid figure
x=r*(theta-sin(theta));
y=r*(1-cos(theta));
end
In Command Window
>> theta=(0:0.01:6*pi);
>> r=5;
>> [x,y]=cycloid(theta,r);
>> plot(x,y), grid
>> xlabel('Abscisse'),ylabel('Ordinate')
>> title('Graph of cycloid')
7
3.2 User defined Function file
8
3.3 Matlab built-in functions
The fzero Matlab function can be used to find the zero of a
function of a single variable 𝒙.
First, 𝒚 = 𝒇 𝒙 function needs to be written in a M-file function.
Second, in the command window, the function
fzero(‘function_name’,x0) can be called to find the zero
crossing closest to the initial guess 𝒙𝟎.
function y = f_1(x)
y=x+2*exp(-x)-3;
In Command Window
>> fzero('f_1',-1) >> fzero('f_1',3)
ans = ans =
-0.5831 2.8887
9
3.3 Matlab built-in functions
y=x+2*exp(-x)-3
10
3.3 Matlab built-in functions
[x,value]=fzero(‘function_name’,x0)
returns the value of the function at the solution x.
[x,value,sol]=fzero(‘function_name’,x0)
returns the value of the function at the solution 𝒙 and returns
if the function found a zero or not.
If the variable 𝒔𝒐𝒍 is positive, then there is a solution, elseif it is
negative, then the function fzero didn’t find a zero.
11
3.3 Matlab built-in functions
12
3.3 Matlab built-in functions
function y = f_1(x)
y=x+2*exp(-x)-3;
In Command Window
>> fminbnd('f_1',0,1)
ans =
0.6932
13
3.3 Matlab built-in functions
[x,value,sol]=fminbnd(‘function_name’, 𝒙𝟏 , 𝒙𝟐 )
returns also if the function converged to a solution or not.
Note:
To find the maximum of a function, use the fminbnd function
with the opposite of the function of interest.
14
Test Your Understanding
Test 3.1
The equation 𝒆−𝟎.𝟐𝒙 𝒔𝒊𝒏 𝒙 + 𝟐 = 𝟎. 𝟏 has three solutions in the
interval 𝟎, 𝟏𝟎 . Find these solutions using Matlab function 𝒇𝒛𝒆𝒓𝒐.
Test 3.2
The function 𝐲 = 𝟏 + 𝒆−𝟎.𝟐𝒙 𝒔𝒊𝒏 𝒙 + 𝟐 has two minimum points in
the interval 𝟎, 𝟏𝟎 . Find the values of 𝒙 and 𝒚 at each minimum
using Matlab function 𝒇𝒎𝒊𝒏𝒃𝒏𝒅.
15
Test 3.1 Matlab solution
function y = f1(x)
%Function f1 in Chapter 3 Test 3.1
y=exp(-0.2*x).*sin(x+2)-0.1;
end
16
Test 3.1 Matlab solution
%Graph of the function difference
x=(0:0.01:10);
y=exp(-0.2*x).*sin(x+2)-0.1;
figure; plot(x,y), grid
xlabel('Abscissa'), ylabel('Amplitude')
title('Graph of the function difference of the equation in Test
3.1')
%On the graph, we see 3 crossings of the function to zero
horizontal axis
%First solution in the interval [0,2] close to initial guess
x01=1
x1=fzero('f1',1); disp('Solution x1= '), disp(x1)
%Second solution in the interval [4,5] close to initial guess
x02=4.5
x2=fzero('f1',4.5); disp('Solution x2= '), disp(x2)
%Third solution in the interval [6,8] close to initial guess
x03=7
x3=fzero('f1',7); disp('Solution x3= '), disp(x3)
17
Test 3.2 Matlab solution
function y = f2(x)
%Function f2 in Chapter 3 Test 3.2
y=1+exp(-0.2*x).*sin(x+2);
end
18
Test 3.2 Matlab solution
%Graph of the function
x=(0:0.01:10);
y=1+exp(-0.2*x).*sin(x+2);
figure; plot(x,y), grid
xlabel('Abscissa'), ylabel('Amplitude')
title('Graph of the function in Test 3.2')
%On the graph, we see 2 function’s minimum in the interval [0,10]
%First minimum in the interval [2,3]
[x1,y1]=fminbnd('f2',2,3);
disp('First minimum abscissa x1= '), disp(x1)
disp('First minimum ordinate y1= '), disp(y1)
%Second minimum in the interval [8,10]
[x2,y2]=fminbnd('f2',8,10);
disp('First minimum abscissa x2= '), disp(x2)
disp('First minimum ordinate y2= '), disp(y2)
19
MATLAB Chapter 4
Advanced Plotting and Model Building
4.1 Plotting 1D functions (Appendix A)
figure
axis([xmin xmax ymin ymax])
grid
plot(x,y)
plot(x1,y1,x2,y2) etc.
legend(‘string1’,‘string2’) etc.
subplot(mnp)
loglog(x,y)
semilogx(x,y)
semilogy(x,y)
polar(theta,r,’type’)
stairs(x,y)
stem(x,y)
4.1 Example A: Archimedes Spirals
• Use Matlab function plot to show the imaginary part versus the
real part from the complex function:
𝒛 𝒏 = 𝟎. 𝟐 + 𝟎. 𝟖𝒊 𝒏 𝟎 ≤ 𝒏 ≤ 𝟐𝟎
Choose enough points to obtain a smooth curve.
%Given data
n=(0:0.1:20);
theta=(0:0.01*pi:6*pi);
%Calculations
z=(0.2+0.8*1i).^n;
x=real(z); y=imag(z);
r=5*theta;
%Output Graph 1
figure; plot(x,y), grid
xlabel('Real part'), ylabel('Imaginary part')
title('Graph of imaginary part with respect to real
part for z(n)=(0.2+0.8i)^n')
4.1 Example A: Archimedes Spirals
%Output Graph 2
figure; subplot(211)
plot(x,y), grid
xlabel('Real part'), ylabel('Imaginary part')
title('Graph of Imaginary part with respect to Real
part for complex z(n)=(0.2+0.8i)^n')
subplot(212)
plot(y,x), grid
xlabel('Imaginary part'), ylabel('Real part')
title('Graph of Real part with respect to Imaginary
part for complex z(n)=(0.2+0.8i)^n')
%Output Graph 3
figure; polar(theta,r)
4.1 Example A: Archimedes Spirals
4.1 Example A: Archimedes Spirals
4.1 Example B: Sampling theorem
%Given data
k1=(0:1:29); k2=(0:2:29);
a=2; b=2*pi*5;
Fs1=10; Ts1=1/Fs1;
Fs2=05; Ts2=1/Fs2;
s1=10*exp(-a*k1*Ts1).*cos(b*k1*Ts1);
s2=10*exp(-a*k2*Ts1).*cos(b*k2*Ts1);
%Output Graph 4
figure; subplot(211), stem(k1,s1), grid,
xlabel('Samples k1'), ylabel('Amplitude')
title('Graph of sampled signal with Sampling period
Ts1=0.1 s = GOOD SAMPLING')
subplot(212), stem(k2,s2,'r'), grid
xlabel('Samples k2'), ylabel('Amplitude')
title('Graph of sampled signal with Sampling period
Ts2=0.2 s = BAD SAMPLING')
4.1 Example B: Sampling theorem
4.2 Data Modelling
3 Basic models:
You can found it easily under the menu APPS in recent Matlab
versions after 2015.
x=[0:0.01:20];
y=exp(-0.05*x).*sin(x);
z=exp(-0.05*x).*cos(x);
plot3(x,y,z)
title('exponentially decaying siprial')
xlabel('x')
ylabel('sine')
zlabel('cosine')
4.3 3D and Surface plots
Example:
Generate a surface plot of the function:
𝒛 = 𝒄𝒐𝒔 𝒙 ∗ 𝒔𝒊𝒏 𝒚𝟐
for -2 x 2 and -3 y 3.
x=-2:0.1:2;
y=-3:0.01:3;
[X,Y]=meshgrid(x,y);
Z=cos(X).*sin(Y.^2);
mesh(X,Y,Z)
xlabel('x'),ylabel('y'),zlabel('z')
Problems
Problems
Problems
MATLAB – Application
Signals & Systems
Outline
2. Fourier Series
3. Fourier Transform
4. Laplace Transform
2
Time-Domain Representation of Signals
Objective:
Model and generate different continuous as well as discrete time signals using MATLAB.
3
Time-Domain Representation of Signals
4
Time-Domain Representation of Signals
5
Time-Domain Representation of Signals
6
Time-Domain Representation of Signals
7
Time-Domain Representation of Signals
8
Time-Domain Representation of Signals
Practice Exercises:
𝒙 𝒏 = −𝟓𝜹 𝒏 + 𝟒 + 𝜹 𝒏 + 𝟐𝜹[𝒏 − 𝟑]
𝒇 𝒕 = 𝒖 𝒕 + 𝒖 𝒕 − 𝟏 + 𝒖 𝒕 − 𝟐 − 𝟑𝒖 𝒕 − 𝟑 −𝟏≤𝒕≤𝟓
c) Verify graphically that the sequences 𝒙𝟏 [𝒏] and 𝒙𝟐 [𝒏] for −10 ≤ 𝑛 ≤ 10 are equal:
𝒙𝟏 𝒏 = 𝟑𝒖 −𝒏 ∗ 𝒖 𝒏 + 𝟓
𝒙𝟐 𝒏 = 𝟑 𝒖 𝒏 + 𝟓 − 𝒖 𝒏 − 𝟏
9
Outline
2. Fourier Series
3. Fourier Transform
4. Laplace Transform
10
Fourier Series (FS)
1. Open the Curve Fitting app by entering cftool. Alternatively, click Curve Fitting on
the Apps tab.
2. In the Curve Fitting app, select curve data (X data and Y data, or just Y data
against index). Curve Fitting app creates the default curve fit, Polynomial.
11
Fourier Series (FS)
Example 1:
>> X=(0:pi/10:10*pi);
1 term
>> Y=sin(X)+0.5+cos(2*X)+cos(5*X)+cos(7*X);
4 terms
8 terms
1
Outline
2. Fourier Series
3. Fourier Transform
4. Laplace Transform
13
Fourier Transform (FT)
Objectives:
1. Determine the Fourier transform of time functions using MATLAB function fourier.
3. Analyze the effect of filtering on a noisy sine wave using MATLAB functions fft, ifft,
and fftshift.
14
Fourier Transform (FT)
Example:
Use MATLAB to find the FT of the following time function:
𝒇 𝒕 = 𝒄𝒐𝒔 𝟑𝒕
MATLAB Solution
15
Fourier Transform (FT)
Example 4:
Use MATLAB to find the inverse FT of the following frequency function:
𝑭 𝒘 =𝝅 𝜹 𝒘−𝟑 +𝜹 𝒘+𝟑
MATLAB Solution
16
Fourier Transform (FT)
Example 4:
Use MATLAB to find the inverse FT of the following frequency function:
𝑭 𝒘 =𝝅 𝜹 𝒘−𝟑 +𝜹 𝒘+𝟑
MATLAB Solution
17
Fast Fourier Transform (FFT)
Example: Low pass Filtering of a sinewave with additive white Gaussian noise
example_filtering_sinewave_with_noise.m
18
Outline
2. Fourier Series
3. Fourier Transform
4. Laplace Transform
19
Laplace Transform (LT)
Objectives:
1. Determine the Laplace transform of time functions using MATLAB function laplace.
4. Use MATLAB function pzmap to represent the constellation of poles and zeros of a
transfer function.
20
Laplace Transform (LT)
Example:
Use MATLAB to find the LT of the following time function:
𝒇𝟏 𝒕 = 𝒆𝒙𝒑 𝒕 𝒇𝟐 𝒕 = 𝒕 𝒆𝒙𝒑 𝒕 𝒇𝟑 𝒕 = 𝒄𝒐𝒔 𝒕
MATLAB Solution
21
Laplace Transform (LT)
Example:
Use MATLAB to find the inverse LT of the following s-domain functions:
𝟏 𝟏 𝒔 𝟏
𝑭𝟏 𝒔 = 𝑭𝟐 𝒔 = 𝑭 𝟑 𝒔 = 𝑭 𝟒 𝒔 =
𝒔−𝟏 𝒔−𝟏 𝟐 𝒔𝟐 + 𝟏 𝒔𝟐 + 𝟏
22
Laplace Transform (LT)
• The LTI system transfer function H(s) is a rational function, given as the ratio of two
polynomials in s.
• These rational functions can be expressed in terms of a partial fraction expansion (PFE).
• Partial fraction expansion can be used in the evaluation of the inverse Laplace transform.
23
Laplace Transform (LT)
Example:
Verify that multiple poles are present in H(s) and evaluate the partial fraction expansion of H(s).
𝟓𝒔𝟒 + 𝟕𝒔𝟑 + 𝟑𝒔𝟐 + 𝟓𝒔 − 𝟑𝟎
𝐇 𝒔 = 𝟒
𝒔 + 𝟒𝒔𝟑 + 𝟕𝒔𝟐 + 𝟔𝒔 + 𝟐
24
“There will come a time when you
believe everything is finished…That
will be the beginning.”
25