Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

EE 331 – Signals And Systems

• Text-book:
– Oppenheim & Willsky, Signals and Systems, 2nd
edition, Prentice Hall.
• It is assumed that you have a background of:
– advanced calculus (complex variables, linear system
theory)
– Laplace and Fourier transforms from Circuit II

PLAN:
Approximately 1 chapter per week
Labs on Mondays
Assistant: Fatih Üstok
2 Midterms, 1 Final, 1 Lab exam

Signals and Systems


• A must for all EE engineers/researchers
• Today’s science and technology is based on
computer based analysis of measured signals from
the nature -> theory of signals and systems is
essential
• With Matlab, it is a joy, a game you can play

• Provides you background to understand product


specifications -> essential for product responsibles,
salers
• Puts mathmetics into practice

1
Auditory signal processing Radar signal processing

These are just a few examples


Biomedical signal processing

2
Why MATLAB?
• Very easy to use
• Lots of built-in functions
• Many users – shared tools, available books
• It is used in: research and development both
in academy and industry
• Hepls you to create figures, movies for your
reports, presentations, etc.

Introduction to MATLAB

It is a console based programing environment!

You can write functions in text files, save in a folder and


call them very easily!

It has a user-friendly editor.

Creating, saving, printing figures is very easy.

How many of you can bring a laptop to the


classroom for Matlab-Lab sessions?

3
Matlab Resources
Introduction to Matlab:
http://www.maths.dundee.ac.uk/~ftp/na-reports/MatlabNotes.pdf
A Practical Introduction to Matlab
http://www.math.mtu.edu/~msgocken/intro/intro.html
Matlab Primer:
http://math.ucsd.edu/~driver/21d-s99/matlab-primer.html
Matlab Course:
http://www.chem.duke.edu/~boris/matlab/

http://www.math.utah.edu/lab/ms/matlab/matlab.html
...

Introduction to MATLAB

4
Introduction to MATLAB

You can write help to your own functions.

Introduction to MATLAB

Defining an array:
>> x=[3.5+4*i -2.1-7.4*i]; row vector
>> x=[3.5+4*i ; -2.1-7.4*i]; column vector
>>x= -5 : 10 : 50; defines an array with boundaries and step

Defining a matrix:
>> A=[1 3 5 7 >> A=[1 3 5 7;2 4 6 8;9 11 13 15]
2468 OR
9 11 13 15]

A= A=

1 3 5 7 1 3 5 7
2 4 6 8 2 4 6 8
9 11 13 15 9 11 13 15

5
Introduction to MATLAB
Size of an array or matrix:
>> x=[1 2 3]; size(x) Without ; => prints on the screen

ans =

1 3
For getting help for a command:
>> y=[1 2;2 3; 4 5];size(y)
>>help size
ans =

3 2
Length of a vector ...
>> length(y)
=max(size(y)) for matrices
ans =

Introduction to MATLAB
Multiplication of vectors and matrices:
>> x=[1 2];y=[3 5]; z=[0 0;1 1];x*y' Vector multiplication

ans =

13
>> x.*y
The dot means ‘element-by-element’
ans =

3 10
>> z*y' Matrix multiplication

ans =

0
8

6
Introduction to MATLAB
Relational operators:

>> C=[1 0 3;4 5 6];D=[1 0 2;0 5 1];


>> disp(C==D), disp(C>D), disp(C&D), disp(C|D)
1 1 0
0 1 0
Displays without the ‘ans’
0 0 1 Logical equal
1 0 1

1 0 1
0 1 1
For and/or type operations,
1 0 1 x≠0 corresponds to 1
1 1 1 x=0 corresponds to 0

Introduction to MATLAB
Control flow commands:
if for while end else elseif break return switch ...

for I = 1:N, switch lower(METHOD)


= 1:1:N
for J = 1:N, case {'linear','bilinear'}
A(I,J) = 1/(I+J-1); disp('Method is linear')
end case 'cubic'
end disp('Method is cubic')
case 'nearest'
if I == J
disp('Method is nearest')
A(I,J) = 2;
otherwise
elseif abs(I-J) == 1
disp('Unknown method.')
A(I,J) = -1;
end
else
A(I,J) = 0;
end Logical equal String definition

7
Introduction to MATLAB
Special characters and variables:
pi inf i % : ... Type ‘help :’ to get a complete list

>> x=i*pi%a complex valued variable


x=
0 + 3.1416i
>> 1/0 >> y=1:5
Warning: Divide by zero. y=
ans = 1 2 3 4 5
Inf
>> x=[1 2;3 5;6 7];x(:,2)
ans =
2
5
7

Introduction to MATLAB
>> whos Lists all current variables
Name Size Bytes Class
All variables are set to
ans 3x1 24 double array
double by default and
x 3x2 48 double array
operations are handled
y 1x5 40 double array
with double precision
>> clear all clears all current variables
>> clear x clears only x
>>global x sets x as global

Functions: m files (save in a .m file in a folder in the path, then


you can call from the command)
function y = mean(x,dim)
.....

8
Introduction to MATLAB
Plotting:
•Initalize a figure
>> figure;plot(1:2:100);axis('tight');
•Plot a signal
>> xlabel('a signal');ylabel('y axis');legend y=2x
•Stretch to ends
•Put a label to x
•Put a label to y
•Switch legend

Figure copy:
Edit/Copy figure
Test yourself:
Edit/Copy options

Introduction to MATLAB

Examples:Plotting a damped oscillation

t=0:0.001:1;

x=10*sin(2*pi*10*t).*exp(-4*t);

plot(t,x);grid;

xlabel('Time');
ylabel('Amplitude')

title('x(t)=10sin(2*pi*10*t)exp(-4*t)');

9
Introduction to MATLAB
Examples: Plotting a sum of two sinusoids

t = -15:0.01:15;
y = cos(pi*t/2) + cos(pi*t/3);
plot(t,y); grid;
xlabel('t (seconds)'); ylabel('y(t)');
title('Plot of y(t)');
print '-djpeg' ‘ex1‘;
Prints to file ex1.jpg
Drill for next lab session:
Write a matlab function (.m file) that accepts frequency of
oscillation, number of samples in a second and the initial phase
(in radians) as input and creates the signal below and plots it.
jωt +φ
x(t ) = e

10
REALITY MODEL

“Signal”
Information in the Mathematical
form of functions
-audio Abstract
- video
- text

“System” State machines


Differential equations
Transforms signals for
Frequency response
-communication
- computation
- storage
- for control Implement
Simulate
Predict
Calculate
Specify design

Örnek: Bir gitarın çıkışını osiloskopa bağladığınızda voltajın sürekli


değişimini gözleyebilirsiniz. Bu, sürekli zamanlı bir işarettir.

11
x[n] is undefined for n
non-integer

12
Sürekli-zaman
Ayrık-zaman

13
Energy of a signal: Application: Gate processing

Remember energy in a circuit element: p(t)=v(t)2/R


Assume v(t) varies with time (is a continuous-time signal)
and we would like to find the energy for a given period of
time: t t
1 2
1 2 v(t ) 2
Eave = ∫ p(t )dt = t 2 − t1 ∫t1 R
dt
t 2 − t1 t1

Similar to this energy description, we compute the energy of


a signal as:
t2
Energy is a“feature” of the signal.
E = ∫ x(t ) dt
2

t1
n2
Not: Buradaki mutlak değer aslında “norm”
E = ∑ x[n] operatörüdür. Sinyalin içeriği kompleks ise
2
vektör boyuna karşılık gelir.
n1

Basic signals – Continuous Time


The Dirac Delta function, often referred to as the unit impulse or
delta function, is the function that defines the idea of a unit impulse.
This function is one that is infinitesimally narrow, infinitely tall, yet
integrates to unity.
d(u(t)) unit step function
δ(t) =
dt

14
Basic signals - CT
Unit step Unit impulse

15
Basic sequences - DT
also named an “impulse”

16
Basic sequences - Matlab
>>x1=zeros(1,20);x1(1)=1;stem(x1)
>> disp(x1)
Columns 1 through 10

1 0 0 0 0 0 0 0 0 0 Unit impulse
Birim dürtü
Columns 11 through 20

0 0 0 0 0 0 0 0 0 0
>> x2=ones(1,20);stem(x2)

Unit step
Birim basamak

17
Basic sequences – Exponential – Continuous Time

x(t)=Ceat
Üstel sinyal

Let’s remember Euler’s identity:

e jϕ + e − jϕ
cos ϕ =
2

e jϕ − e − jϕ
sin ϕ =
2j

Phasors:
e j (ω0t +ϕ ) + e − j (ω0t +ϕ )
A cos(ω0t + ϕ ) =
2

18
Complex Exponential Function: frequency

Ce at = C e jθ e ( r + jω0 )t = C e rt e j (ω0t +θ )
Exponential Oscillator
a = r + jω 0
{ }
envelope
x(t ) = ℜ Ce at

frequency

Basic sequences - Exponential


Gerçek üstel sinyal
>> A=5;alfa=0.8;
>> for k=1:20; x(k)=A*alfa^k;end
>> stem(x)

Power of a complex variable -> rotation

>> A=5;alfa=0.6+i*0.5;
for k=1:200; x(k)=A*(alfa^k);end
plot(x,'.');grid;
Karmaşık üstel sinyal/dizi

19
Basic sequences - Exponential
for w=0:pi/200:pi/2
alfa=r*exp(i*w);
frequency of oscillation in
for k=1:K
radians
x(k)=A*(alfa^k);
end
end

Exponential envelope frequency phase

Basic sequences - Exponential


Special case: α=1

Oscillation on a circle in complex plain

!! –π < ω < π or 0 < ω < 2π

What is the maximum


frequency? ☺

20
Periodic continuous-time signals

Phasor representation: A∟θ


What about negative frequency? How is it possible?

Basic sequences - Sinusoidal

!! –π < ω < π or 0 < ω < 2π

Periodic sequences:
>>n=0:100;
>>x=cos(pi/20*n+0);
>>stem(x);hold;plot(x);hold

What is the period of x[n]?

21
Period of an oscillatory signal
π π
cos( n + 0) = cos( (n + N ) + 0)
20 20
π π π
n + 2πk = n+ N
20 20 20

π
2πk = N
20

N = 40

What about the period of this signal?


x[n] = cos(n)

Period of an oscillatory signal

cos(n + 2πk ) = cos(n + N )


N = 2πk no integer solution

!! cos(n) is an aperiodic signal ... due to discrete time

Indistinguishable frequencies: integer

cos(ωo n) = cos((ωo + 2πr )n) ωo = ωo + 2πr

22
Does this property hold
for continuous time
signals?

Let’s try this ourselves in Matlab:


>> n=1:100;
>> x=cos(n*pi/8); y=cos(n*15*pi/8);
>> figure;plot(x,'o');hold;stem(y,'.');hold;zoom on
>> legend 'cos(n*pi/8)' 'cos(n*15pi/8)'

23
Basic sequences – Continuous Time
Euler’s relation:

24
Transformations of the independent variable

reflection about the origin, x[-n], x(-t)

Let’s do it in Matlab
>>cd D:\dersNotlari\EE331_SignalsAndSystems\lecture1wav
>>[s,SamplingFreq]=wavread(‘ses.wav’);
>>soundsc(s, SamplingFreq);
>>s2=s(length(s):-1:1);
>>soundsc(s2, SamplingFreq);

25
Transformations of the independent variable
Time scaling Time shift

Sampling demo
>> cd
D:\baris\dersler\dersNotlari\EE331_SignalsAndSy
stems\DEMOS\con2dis-v200\con2dis
>> con2dis

26
Bunlar neden önemli?

Çünkü sinyallerde
temel işlemler bunlar,
ders boyunca
karşılaşacağız.

27
f (t ) = f (−t )

f (t ) = − f (−t )

!! Any signal can be written as a combination of an even and


an odd signal. How ??

1 1
f (t ) = ( f (t ) + f (−t )) + ( f (t ) − f ( −t ))
2 2
Even part Odd part

Obtaining the even part

28
Obtaining the odd part

Reading assignment:
Chap. 1 – Introduction
Chap. 2 – Signals and Systems

29

You might also like