0% found this document useful (0 votes)
28 views

Lecture 2

This document provides an overview of MATLAB and discusses: 1) How to define and manipulate variables, perform basic calculations, and plot functions. 2) How to view the workspace, clear variables, save and load data, and get help. 3) Examples of plotting a composite function h(t)=f(t)g(t) where f(t)=cos(20πt) and g(t)=e-10t from t=0 to 0.2.

Uploaded by

khaddamoaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Lecture 2

This document provides an overview of MATLAB and discusses: 1) How to define and manipulate variables, perform basic calculations, and plot functions. 2) How to view the workspace, clear variables, save and load data, and get help. 3) Examples of plotting a composite function h(t)=f(t)g(t) where f(t)=cos(20πt) and g(t)=e-10t from t=0 to 0.2.

Uploaded by

khaddamoaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Signal and Systems

Background
Sinusoids
• The general form of a sinusoid is
• 𝑥 𝑡 = 𝐶 cos 2𝜋𝑓0 𝑡 + 𝜃
• 𝐶 is the amplitude
• 𝑓0 is the frequency in 𝐻𝑧
• 𝜃 is the phase in 𝑟𝑎𝑑
• 𝜔0 = 2𝜋𝑓0 is the radian frequency in 𝑟𝑎𝑑Τ𝑠
• ⇒ x 𝑡 = 𝐶 cos 𝜔0 𝑡 + 𝜃
• Where
2𝜋
• 𝜔0 = 2𝜋𝑓0 = 𝑟𝑎𝑑 Τ𝑠
𝑇0
Sinusoids
1 1
• 𝑓0 = = 𝑠 −1 = 𝐻𝑧
𝑇0 𝑠
2𝜋 1
• 𝑇0 = = 𝑠𝑒𝑐𝑜𝑛𝑑𝑠
𝜔0 𝑓0
• 𝜔0 : radian frequency
• 𝑓0 : Hurtzian frequency
Sinusoids
• Remember:
𝜋
• cos 𝜔0 𝑡 − = sin 𝜔0 𝑡
2
𝜋
• cos 𝜔0 𝑡 + = − sin 𝜔0 𝑡
2
𝜋
• sin 𝜔0 𝑡 − = − cos 𝜔0 𝑡
2
𝜋
• sin 𝜔0 𝑡 + = cos 𝜔0 𝑡
2
Addition of Sinusoids
• 𝑎 cos 𝜔0 𝑡 + 𝑏 sin 𝜔0 𝑡 = 𝑐 cos 𝜔0 𝑡 + 𝜃
• How to find 𝑐 and 𝜃?
• 𝑎 − 𝑗𝑏 = 𝑐𝑒 𝑗𝜃
• ⇒ 𝑐 = 𝑎2 + 𝑏 2
𝑏
• 𝜃= tan−1 −
𝑎
Addition of Sinusoids
• Example: Express 𝑥 𝑡 = cos 𝜔0 𝑡 − 3 sin 𝜔0 𝑡 as a single sinusoid
Addition of Sinusoids
• Example: Express 𝑥 𝑡 = cos 𝜔0 𝑡 − 3 sin 𝜔0 𝑡 as a single sinusoid
Addition of Sinusoids
• Example: Express 𝑥 𝑡 = −3 cos 𝜔0 𝑡 + 4 sin 𝜔0 𝑡 as a single
sinusoid
Addition of Sinusoids
• Example: Express 𝑥 𝑡 = −3 cos 𝜔0 𝑡 + 4 sin 𝜔0 𝑡 as a single
sinusoid
Sketching Signals
• Monotonic Exponentials
• 𝑥 𝑡 = 𝐶𝑒 𝑎𝑡
• Case 1: If 𝐶 and 𝑎 are real
Sketching Signals
• Case 2: 𝐶 is complex, 𝑎 is pure imaginary
• 𝐶 = 𝐴𝑒 𝑗𝜙
• 𝑎 = 𝑗𝜔0
• 𝑥 𝑡 = 𝐶𝑒 𝑎𝑡 = 𝐴𝑒 𝑗𝜙 𝑒 𝑗𝜔0 𝑡 = 𝐴𝑒 𝑗 𝜔0 𝑡+𝜙
• ∴ 𝑥 𝑡 = 𝐴 cos 𝜔0 𝑡 + 𝜙 + 𝑗𝐴 sin 𝜔0 𝑡 + 𝜙
• 𝑥𝑅 𝑡 = 𝐴 cos 𝜔0 𝑡 + 𝜙
• 𝑥𝐼 𝑡 = 𝐴 sin 𝜔0 𝑡 + 𝜙
Sketching Signals
• How much is the time-shift caused by 𝜙?
Sketching Signals
• How much is the time-shift caused by 𝜙?
𝜙
• cos 𝜔0 𝑡 + 𝜙 = cos 𝜔0 𝑡 +
𝜔0
−𝜙
• ⇒ the time-shift is 𝑠𝑒𝑐𝑜𝑛𝑑𝑠
𝜔0
Sketching Signals
• Case 3: 𝐶 and 𝑎 are complex
• 𝐶 = 𝐴𝑒 𝑗𝜙
• 𝑎 = 𝜎0 + 𝑗𝜔0
• 𝑥 𝑡 = 𝐶𝑒 𝑎𝑡 = 𝐴𝑒 𝑗𝜙 𝑒 𝜎0 +𝑗𝜔0 𝑡 = 𝐴𝑒 𝜎0 𝑡 𝑒 𝑗 𝜔0 𝑡+𝜙
• ∴ 𝑥 𝑡 = 𝐴𝑒 𝜎0 𝑡 cos 𝜔0 𝑡 + 𝜙 + 𝑗𝐴𝑒 𝜎0𝑡 sin 𝜔0 𝑡 + 𝜙
• 𝑥𝑅 𝑡 = 𝐴𝑒 𝜎0𝑡 cos 𝜔0 𝑡 + 𝜙
• 𝑥𝐼 𝑡 = 𝐴𝑒 𝜎0𝑡 sin 𝜔0 𝑡 + 𝜙

• (Sketches are on the next slide)


Sketching Signals
Useful Mathematical Formulas
Useful Mathematical Formulas
Useful Mathematical Formulas
Useful Mathematical Formulas
MATLAB Overview
• MATLAB is a registered trademark of the MathWorks Inc.
• Entering instructions at the command prompt generally results in the
creation of an object or objects.
• Objects are placed in what is called the MATLAB workspace.
• workspace provides important information about each object,
including the object’s name, size, and class.
• Another way to view the workspace is the whos command.
• clear removes all objects from the workspace. If followed by the
variable name, it will clear that variable only.
• clc command clears the command window.
MATLAB Overview
• clf command clears the current figure window.
• The save command, followed by the desired filename, saves the
entire workspace to a file for future use, which has the .mat
extension.
• The save followed by the filename and then the names of the
objects to be saved, selectively saves those objects.
• The load command followed by the filename is used to load the data
and objects contained in a MATLAB data file (.mat file).
• Pressing the up or down arrow key scrolls through previous
commands and redisplays them at the command prompt.
MATLAB Overview
• Typing the first few characters and then pressing the arrow keys scrolls
through the previous commands that start with the same characters.
• Typing help followed by the function name displays helpful text in the
command window. The obvious shortcoming of help is that the function
name must first be known.
• Fortunately, help also displays related or similar functions, which is an
excellent way to learn new MATLAB commands.
• Alternatively, doc followed by the function name opens up the
documentation page for that function name, giving more details about the
function in question.
• The lookfor command helps locate MATLAB functions based on a
keyword search.
MATLAB Overview
• The print command can save figures in a common file format such
as postscript, encapsulated postscript, JPEG, or TIFF.
• The format of displayed data, such as the number of digits displayed,
is selected by using the format command.
• The exit command terminates MATLAB.
MATLAB Overview – Calculator Operations
• MATLAB can function as a simple calculator, working as easily with
complex numbers as with real numbers.
• >> z = -3-4j
assigns the complex constant −3 − 𝑗4 to the variable 𝑧.
MATLAB Overview – Calculator Operations
• The real and imaginary components of z are extracted by
>> z_real = real(z); z_imag = imag(z);
• When a command is terminated with a semicolon, the statement is
evaluated but the results are not displayed to the screen.
• The magnitude of a complex number can be calculated as
>> z_mag = sqrt(z_real^2 + z_imag^2)
>> z_mag = sqrt(z*conj(z))
>> z_mag = abs(z)
• The angle of a complex number is calculated as
>> z_rad = angle(z)
>> z_rad = atan2(z_imag,z_real)
MATLAB Overview – Calculator Operations
• MATLAB expects and returns angles in a radian measure.
Angles expressed in degrees require an appropriate conversion factor.
>> z_deg = angle(z)*180/pi
• MATLAB supports a full complement of trigonometric
Function: cos, sin, tan, sec, csc, cot, acos, asin,
atan, asec, acsc, acot, cosh, sinh, tanh, sech,
csch, coth, acosh, asinh, atanh, asech, acsch
• >> cos(1j) is , since complex!
• In MATLAB, ase-10 and base-e logarithms are computed by using the
log10 and log commands, respectively.
MATLAB Overview – Elementary Operations
• The * operator is used to perform the inner product and the outer
product:
• A 1 × 𝑁 row vector times an 𝑁 × 1 column vector results in the scalar-
valued inner product.
• An 𝑁 × 1 column vector times a 1 × 𝑀 row vector results in the outer
product, which is an 𝑁 × 𝑀 matrix.
• Element-by-element multiplication, division, and exponentiation are
accomplished using .*, ./, and .^, respectively.
MATLAB Overview
• Example: Plot ℎ 𝑡 = 𝑓 𝑡 𝑔 𝑡 , where 𝑔 𝑡 = 𝑒 −10𝑡 and 𝑓 𝑡 =
cos 20𝜋𝑡 from 𝑡𝑠𝑡𝑎𝑟𝑡 = 0 𝑠 till 𝑡𝑒𝑛𝑑 = 0.2 𝑠
MATLAB Overview
• Example: Plot ℎ 𝑡 = 𝑓 𝑡 𝑔 𝑡 , where 𝑔 𝑡 = 𝑒 −10𝑡 and 𝑓 𝑡 =
cos 20𝜋𝑡 from 𝑡𝑠𝑡𝑎𝑟𝑡 = 0 𝑠 till 𝑡𝑒𝑛𝑑 = 0.2 𝑠
clc; plot(t, f, '-k', t, h, ':k'); figure,
close all; xlabel('t'); plot(t, f, '-k', 'LineWidth', 2);
clear all; ylabel('Amplitude'); hold, plot(t, h, ':k', 'LineWidth', 2);
legend('f(t)', 'h(t)'); xlabel('t');
title('f(t) and h(t)'); ylabel('Amplitude');
t = 0:0.001:0.2; grid; title('f(t) and h(t)');
f = cos(20 * pi * t); legend('f(t)', 'h(t)');
g = exp(-10 * t); grid;
h = f .* g;
MATLAB Overview
• Example: Plot ℎ 𝑡 = 𝑓 𝑡 𝑔 𝑡 , where 𝑔 𝑡 = 𝑒 −10𝑡 and 𝑓 𝑡 =
cos 20𝜋𝑡 from 𝑡𝑠𝑡𝑎𝑟𝑡 = 0 𝑠 till 𝑡𝑒𝑛𝑑 = 0.2 𝑠

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy