You are on page 1of 27

Practical Signal Processing Concepts and Algorithms using MATLAB

Fundamentals of Signals
2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-1

Fundamental of Signals

What is signal Processing?

The scope of signal processing has grown so broad as to obviate a perfect and precise definition of what is entailed in it Traditionally, signal processing includes the materials thought in DSP courses but now signal processing has greater reach because of its influence on related disciplines such as controls, communications theory and also digital communication. Thus, signal processing can be defined as that area of applied mathematics that deals with operations on or analysis of signals, in either discrete or continuous time, to perform useful operations on those signals.

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-2

Fundamental of Signals

Digital signal processing is the process of extracting useful information from an incoming set of signal (sampled at regular interval, Ts)

When you speak, your voice is picked up by an analog sensor in the cell phones microphone

An analog-todigital converter chip converts your voice (analog) into digital signals, representing 1s and 0s

The Digital Signal Processor (DSP) compresses the digital signals and remove any noise.

In the receivers cell phone, a digital-to-analog converter chip changes the digital signal back to an analog voice signal

Your voice exits the phone through the speaker

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-3

Fundamental of Signals

What is Signal Processing Toolbox?

The Signal Processing Toolbox is a collection of tools built on the MATLAB numeric computing environment. The toolbox supports a wide range of signal processing operations, from waveform generation to filter design and implementation, parametric modeling, and spectral analysis. The toolbox provides two categories of tools.

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-4

Fundamental of Signals

Section Outline

Creating and importing signals Sampling and re-sampling Signal visualization Modeling noise Modulation

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-5

Fundamental of Signals

Discrete Signals
Time base: t = [0.0 0.1 0.2 0.3]; Signal data: x = [1.0 3.2 2.0 8.5];

Creating vectors in MATLAB:


>> t = [0.0 0.1 0.2 0.3]; >> t = 0:0.1:0.3; >> t = linspace(0, 0.3, 4);
2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-6

Fundamental of Signals

Sampling Signals
Analog signal sources
Electromagnetic, audio, sonar, biomedical

Sampling

x(n) xa (nTs )
discrete signal analog signal sample time

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-7

Fundamental of Signals

Aliasing
Shannon Sampling Theorem:
fs 2 fM

fs 2 fM
fs 2 fM

Original signal and sampled signal have same frequency


2010 Trity Technologies Sdn Bhd. All Rights Reserved

Sampled signal is aliased to half the original frequency


2-8

Fundamental of Signals

Signal Visualization

View signal amplitude vs. time index Functions
plot, stem, stairs, strips

Listen to data
sound

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-9

Fundamental of Signals

Signal Processing Tool

2010 Trity Technologies Sdn Bhd. All Rights Reserved

>> sptool

2-10

Fundamental of Signals

Importing a Signal
Choose Import under the File menu

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-11

Fundamental of Signals

Signal Processing Basics


Common Sequences

Since MATLAB is a programming language, an endless variety of different signals is possible. Here are some statements that generate several commonly used sequences, including the unit impulse, unit step, and unit ramp functions: >> t = (0:0.01:1); >> y = ones(101); >> y = t ; % step % ramp >> y = [1; zeros(100,1)]; % impulse

>> y = t.^2;

% exponential

>> y = square(2*pi*4*t); % generates a square wave every 0.25secs.

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-12

Fundamental of Signals

Waveform generation

>> y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);

%two sinusoids, %one at 50 Hz %and one at %120Hz with %twice the amplitude %plot y versus time
%display only the first %50 points(zoom!)

>> plot(t,y)
>> plot(t(1:50),y(1:50))

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-13

Fundamental of Signals

Signal Browser

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-14

Fundamental of Signals

Changing Sample Rates


To change the sample rate of a signal in SPTool, 1. Click one signal in the signals column of SPTool. 2. Select Sampling Frequency in the Edit menu. 3. Enter the desired sampling frequency and click OK.

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-15

Fundamental of Signals

Signal Generation
Signals Create a time base vector
>> t = [0:0.1:2];

Signal as function of time


>> x = sin(pi*t/2);

Useful MATLAB Functions

Nonperiodic functions
ones, zeros, step

Periodic functions
sin, cos, square, sawtooth

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-16

Fundamental of Signals

Non-periodic Signals
>> t = linspace(0,1,11)

Step
>> y = ones(11,1);

Impulse
>> y = [1;zeros(10,1)];

Ramp
>> y = 2*t;
2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-17

Fundamental of Signals

Sine Waves
Parameters

Amplitude A Frequency f Phase shift Vertical offset B

General form

y A sin(2ft ) B A sin(2f (t )) B
2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-18

Fundamental of Signals

Square Waves
>> sqw1 = square(2*pi*4*t);

Duty cycle is 50% (default) Frequency is 4 Hz

>> sqw2 = square(2*pi*4*t,75);

Duty cycle is 75% Frequency is 4 Hz

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-19

Fundamental of Signals

Sawtooth Waves
>> saw1 = sawtooth(2*pi*3*t);

Peak at end of cycle (default) Frequency is 3 Hz

>> saw2 = sawtooth(2*pi*3*t,1/2);

Peak halfway through cycle Frequency is 3 Hz

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-20

Fundamental of Signals

Complex Signals
x(t) = e j2ft = cos(2 ft) + j sin(2 ft) = cos(t) + j sin(t)
>> x = exp(2*pi*j*f*t);

Useful MATLAB Functions: real, imag, abs, angle

Fs/2

0,Fs

z-plane: e j
2010 Trity Technologies Sdn Bhd. All Rights Reserved

Time domain: sin(t)


2-21

Fundamental of Signals

input textread

Importing Data

xlsread

imread importdata
2010 Trity Technologies Sdn Bhd. All Rights Reserved

wavread uiimport

2-22

Fundamental of Signals

Modeling Noise with Random Data


>> un = -5+10*rand(1,1e6); >> gn = 10+5*randn(1,1e6); >> hist(gn,100) >> hist(un,100) Uniform Gaussian

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-23

Fundamental of Signals

Adding Noise to a Signal


noisy signal = signal + noise
>> y1 = x + rand(size(x)) >> y2 = x + randn(size(x)) uniform noise Gaussian noise

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-24

Fundamental of Signals

Pseudorandomness
0.95012928514718 This is the first number produced by the MATLAB uniform random number generator with its default settings. Is it random?
A random sequence is a vague notion ... in which each term is unpredictable to the uninitiated and whose digits pass a certain number of tests traditional with statisticians ...
- D.H. Lehmer

>> rand('state',s) Sets the state to s. >> rand('state',0) Resets the generator to its initial state. >> rand('state',sum(100*clock)) New state each time.
2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-25

Fundamental of Signals

Resampling
Useful MATLAB functions
downsample, upsample, resample, interp, decimate

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-26

Fundamental of Signals

Modulation and Demodulation


y = modulate(x,fc,fs,'fm')

x = demod(y,fc,fs,'fm')

2010 Trity Technologies Sdn Bhd. All Rights Reserved

2-27

You might also like