0% found this document useful (0 votes)
11 views28 pages

CMP4101 Signal Analysis in The Time Domain

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)
11 views28 pages

CMP4101 Signal Analysis in The Time Domain

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/ 28

CMP4101/TEL4111: Digital Signal Processing

Cosmas Mwikirize, Ph.D


Department of Electrical and Computer Engineering, Makerere
University

© Cosmas Mwikirize, 2022


Announcements

• MUELE Course has been created.


• CMP4101/TEL4111 Semester 1 2021/2022,
Enrolment instance DSP22
• Enrolment key: DSP22
• We shall not have a lecture next week. Assignment 1 is
live, and will be due February 26, 11.59pm
The Roadmap

Signal Analysis Signal Analysis Signal Analysis


Introduction
in the Time in the in the
-The big picture: Domain Linear Systems The Z
Frequency Frequency
signals and Analysis in the Transform and Window
-Time Domain Domain: Domain:
systems Time Domain: application to Functions
Measurements Fourier Series Implications
-Digital vs Convolution Filters
-Time Domain and Fourier and
Analog signals Transformation applications
Analysis
Signal Analysis in the Time
Domain
End date: February 26, 2022
The basic waveform: Sinusoids

• A sinusoid is any signal that follows a basic sine wave pattern at a single
frequency
• It can be real-valued or complex (all real-world signals are real-valued).

• General:

A: amplitude, 𝜔𝑝 is frequency in rad/s, 𝑓𝑝 is frequency in Hz, T is period (s), t is the


time in seconds

Recall:

A general real-valued signal is a sine or cosine with a non-zero phase term

5
Intro to MATLAB for DSP
Example 2.1
Use MATLAB to construct a sinusoidal signal having an amplitude of 5.5 and a
frequency of 10 Hz. Construct the signal in a 1000-point array. Assume a
sampling frequency fs = 1000 Hz
Solution:
Step 1: Number of data points in the signal. Here, we are given N=1000 (If not
given, use this as some sort of default)’
Step 2: Construct a time vector of the same length as N. The discrete points in
time are determined by the sample interval, 𝑇𝑠 or the sample frequency fs :
𝑛
𝑡 = 𝑛 𝑇𝑠 =f (n is the position of the signal value in the sequence, and goes from
s
1 to N (same as 0 to N-1)
Step 3: (Code): Write the script

6
Intro to MATLAB for DSP

7
Signal Properties: Basic Measurements
• Most signals are complicated and defy a straightforward analytical
description.
• Basic measurements can be applied to extract more information

8
Mean of a Signal
• Discrete signal: Add signal values and divide by the length of the

1 𝑁
𝑥ҧ = σ 𝑥
𝑁 𝑛=1 𝑛

• Continuous signal: Integrate the signal over time and divide by the
time length

Demo: mean of sine signal


Matlab: mean(x)

9
Root Mean Square Value
• Mean does not give information about variability of a signal
• Root-Mean-Square (RMS) value: Square, Take the Mean, then take
the square root of the mean.

1
1 𝑁
Discrete signal: 𝑥𝑟𝑚𝑠 = σ𝑛=1 𝑥𝑛2 2
𝑁
1
1 𝑇 2 𝑑𝑡 2
Continuous signal: 𝑥𝑟𝑚𝑠 = ‫׬‬ 𝑥(𝑡)
𝑁 0

We shall focus on the discrete versions of these equations, which easy to


Implement on computers (the whole point of DSP!!)

Demo: RMS of a sinusoid


Matlab: rms(x)
10
RMS: MATLAB example
Example 2.2
Find the rms value of the sinusoid signal 𝑥 𝑡 = sin(8𝜋𝑡)

Solution:
Refer to Example 2.1. Here, N is not given so we can arbitrarily choose N=1000.
We are also not given a sampling frequency. Following Nyquist’s theorem, the
sampling frequency should be at least twice the highest frequency in the signal
(this time, the constant frequency of 4 Hz). The higher the better. Let us then
arbitrarily choose fs = 1000 Hz.

Result of 0.7071 displays in the command window


11
Decibels
– It is common to compare intensity of signals using ratios, e.g.,
signal vs noise in the same waveform.
– These signal ratios are usually represented in decibels (dB)
– When applied to power measurements:
𝑃2
𝑃𝑑𝐵 = 10 log 𝑑𝐵
𝑃1
Since power is proportional to the square of the amplitude (rms),
the dB is defined as
𝑣22 𝑣2
𝑣𝑑𝐵 = 10 log 2 = 20 log
𝑣1 𝑣1
or 20 log 𝑣𝑟𝑚𝑠 for a single signal.

12
Signal to Noise Ratio
– Most waveforms consist of signal + noise
– One of the goals of DSP is to separate the signal from noise
– The signal-to-noise-ratio or SNR quantifies the relative amount
of signal and noise.
𝑠𝑖𝑔𝑛𝑎𝑙
𝑆𝑁𝑅 = 20 log 𝑑𝐵 , both measured in rms amplitude
𝑛𝑜𝑖𝑠𝑒
o Positive SNR: Signal is greater than noise
o Negative SNR: Noise is greater than signal

13
SNR Example
Example 2.3
Consider a sinusoid signal contaminated with various amounts of white noise.

14
Variance and Standard Deviation
• Mean and rms apply to both deterministic and stochastic signals
• However, some properties only describe a signal’s random behavior. The
most common is the signal variance (randomness/fluctuation/variability), 𝜎 2

1
• For discrete signals, 𝜎 2 = 𝑁−1 σ𝑁
𝑛=1(𝑥𝑛 − 𝑥ҧ )
2

where 𝑥ҧ is the mean of the signal’

𝜎, the square root of the variance is the standard deviation.


• When 𝑥ҧ = 0, 𝜎 is almost equal to the rms value.

Quiz: The small difference between rms and 𝜎 when 𝑥ҧ = 0 lies in the division
by N vs N-1. Why do we divide by N-1 when calculating the variance?

15
Standard Deviation Example
Example 2.4
Generate a 5000-point array of Gaussian distributed i.e., normal numbers and
calculate the standard deviation of those numbers.
Solution
Use randn to generate the array, std to calculate the standard deviation
(Help in MATLAB always comes in hand e.g…

As expected, the std is 1.00


16
Averaging for Noise Reduction

• If multiple measurements are added, the mean and variance of the


combined signal are the averages of the individual means and variances

1
𝜎 2 = 𝑁 σ𝑁
𝑛=1(𝜎𝑛 )
2

• However, the standard deviations of the noise components are reduced by


1
a factor 𝑁, where N is the number of measurements being averaged.

𝜎
𝜎𝑛𝑜𝑖𝑠𝑒 =
𝑁
• Therefore, averaging multiple measurements from the same sources
reduces the standard deviation of the measurement’s noise, by the square
root of the number of measurements. It is thus common to make multiple
measurements wherever possible and average the results.

17
Ensemble Averaging

• The use of averaging to reduce noise can be applied to an entire signal


• We make multiple observations on the same system. This could be from
multiple sensors or repeated responses to the same stimulus.
• This requires a time reference. We then take a point-by-point average

18
Time Domain Analysis: Correlation
• The basic measurements of mean, variance, standard deviation, and rms
capture the most important features of a signal.

• However, more insight could be obtained by comparing the signals with


reference signals.
• Correlation quantifies how much one signal is like another.

• Linear correlation between two signals can be obtained using Pearson


correlation coefficient, 𝑟𝑥𝑦 :
1
𝑟𝑥𝑦 = (𝑁−1)𝜎 σ𝑁
𝑛=1(𝑥𝑛 − 𝑥)
ҧ (𝑦𝑛 − 𝑦)

𝑥 𝜎𝑦

This equation scales the correlation coefficient to be between ±1, but if we are not
concerned with the scale, then it is not necessary to normalize with the standard
deviations and N-1.

If the means are zero, then the correlation can simply be approximated by:
1
𝑟𝑥𝑦 = σ𝑁
𝑛=1 𝑥 𝑛 𝑦[𝑛]
(𝑁)

19
Example 2.5

Three pairs of signals and the normalized correlation between them. Note the high correlation between
The sine and triangle wave (center) and the zero correlation between the sine and cosine (top)

20
Time Domain Analysis: Covariance

• Covariance computes the variance shared between two or more signals

1
cov= (𝑁−1) σ𝑁
𝑛=1(𝑥𝑛 − 𝑥)
ҧ (𝑦𝑛 − 𝑦)

This equation is like that for computing the Pearson Correlation, except that it is
1
not normalized by 𝜎 𝜎
𝑥 𝑦

21
Orthogonal signals and orthogonality

• Orthogonal: perpendicular
• If two signals are orthogonal, then:

σ𝑁
𝑛=1 𝑥 𝑛 𝑦[𝑛]=0

This is similar to the Pearson Coefficient expression without normalization.

Therefore, orthogonal signals are uncorrelated and vice versa.

MATLAB: correlation: corrcoef


covariance: cov

22
Cross correlation

• Repeated shifting and correlation of a reference signal across the entire target
signal, to get the best match
• Used to determine similarity between a signal and a reference waveform when
the relative position for the best match is unknown.
• Works even when reference is shorter than target

𝑁
1
𝑟𝑥𝑦 𝑘 = ෍ 𝑦[𝑛]𝑥 𝑛 + 𝑘
𝑁
𝑛=1

Where k is the shift variable, which ranges over positive and negative integers, up
to some max value.

If two signals are the same length and one is shifted, there are no matching points.
The signal that is short is extended with zeros to extend computation beyond a
nominal point, a practice known as zero padding.

23
Example 2.6

24
Autocorrelation

• Correlating a signal with itself


• Could be used to determine how signal data points correlate with their
neighbors

𝑁
1
𝑟𝑥𝑥 𝑘 = ෍ 𝑥[𝑛]𝑥 𝑛 + 𝑘
𝑁
𝑛=1

Where k is the shift variable, which ranges over positive and negative integers, up
to some max value.

25
Example 2.7

26
Autocovariance and Cross covariance

• Closely resemble autocorrelation and cross correlation


• Here, the means are subtracted from the input signals.

Cross covariance
𝑁
1
𝐶𝑥𝑦 𝑘 = ෍ (𝑥 𝑛 − 𝑥 𝑛 )(𝑦 𝑛 + 𝑘 − 𝑦 𝑛 )
𝑁
𝑛=1

Autocovariance
𝑁
1
𝐶𝑥𝑥 𝑘 = ෍ (𝑥 𝑛 − 𝑥 𝑛 )(𝑥 𝑛 + 𝑘 − 𝑥 𝑛 )
𝑁
𝑛=1

The autocorrelation can be thought of as measuring the memory or self-similarity of


the deviation of a signal about its mean level.

27
Practice Questions

1. If a signal is measured as 2.8V and the noise is 30mV, what is the SNR in dB?
2. A single sinusoid signal is buried in noise. If the rms value of the noise is 0.6V and
the SNR is 20dB, what is the rms amplitude of the sinusoid?
3. Two 30Hz sine waves have a relative phase shift of 300 . What is the time
difference between them? If the frequency of these sine waves doubles, but the
time difference stays the same, what is the phase difference between them?
4. Replicate all the MATLAB examples in this lecture set.

You might also like