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

Igital Ignal Rocessing: Balochistan University of Information Technology, Engineering & Management Sciences-Quetta

This document discusses digital signal processing concepts including fast Fourier transforms (FFTs) and inverse fast Fourier transforms (IFFTs). It provides theoretical background on FFTs, describing how they are used to break down time domain signals into their constituent frequency components. The document then shows MATLAB code to generate three time domain signals with different frequencies, combine them, and perform an FFT on the combined signal. Finally, it discusses implementing FFTs and IFFTs in Simulink models to transform between time and frequency domains.

Uploaded by

Wadan Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Igital Ignal Rocessing: Balochistan University of Information Technology, Engineering & Management Sciences-Quetta

This document discusses digital signal processing concepts including fast Fourier transforms (FFTs) and inverse fast Fourier transforms (IFFTs). It provides theoretical background on FFTs, describing how they are used to break down time domain signals into their constituent frequency components. The document then shows MATLAB code to generate three time domain signals with different frequencies, combine them, and perform an FFT on the combined signal. Finally, it discusses implementing FFTs and IFFTs in Simulink models to transform between time and frequency domains.

Uploaded by

Wadan Shah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

DIGITAL SIGNAL PROCESSING

BALOCHISTAN UNIVERSITY OF INFORMATION TECHNOLOGY,


ENGINEERING
& MANAGEMENT SCIENCES- QUETTA

Name: Israr Ahmad________

CMS ID: 43525 __________

Session: Fall2019________

Submitted To: Engr. Ali Israr

Date: __11-10-2019_______
TABLE OF CONTENTS

LAB’s

1. INTRODUCTION TO MATLAB

1.1. GETTING STARTED WITH MATLAB


1.2. EXERCISE

2. SIGNAL GENERATION
2.1. EXERCISE

3. INTRODUCTION TO SIMULINK IN MATLAB


3.1. GENERATES DIFFERENT TYPES OF FUNCTION IN
MATLAB
3.1.1. RAMP FUNCTION
3.1.2. UNIT STEP FUNCTION
3.1.3. RECTANGLE FUNCTION
3.1.4. SINC FUNCTION
3.1.5. TRIANGULAR FUNCTION
3.1.6. IMPULSE FUNCTION
3.2. EXERCISE

4. TO UNDERSTAND AND IMPLEMENT THE CONCEPT OF SAMPLING


AND NYQUIST SAMPLING THEOREM IN MATLAB.
4.1. IMPLEMENTATION OF SAMPLING AND NYQUIST SAMPLING
THEOREM IN SIMULINK.
4.2. EXERCISE

5. LINEAR CONVOLUTION OF TWO GIVEN SEQUENCES


5.1. USING MATLAB’S “CONV” FUNCTION
5.2. USING THE LINEAR CONVOLUTION SUM FORMULA
5.3. EXERCISE

6. TO UNDERSTAND FFT & IFFT OF THE TIME DOMAIN SIGNALS


6.1. TO WRITE THE MATLAB CODE TO PERFORM FAST FOURIER
TRANSFORM ON THREE DIFFFERENT CONTINUOUS TIME
DOMAIN SIGNALS.
6.2. IMPLEMENTATION OF FFT & IFFT IN SIMULINK.
LAB 6
TO UNDERSTAND PLOT FFT & IFFT OF THE
DIFFERENT SIGNALS
Aim: To write the MATLAB code to perform Fast Fourier Transform on three
different continuous time domain signals.
Theory:
A fast Fourier transform (FFT) is an algorithm that samples a signal over a period of time
(or space) and divides it into its frequency components. These components are single sinusoidal
oscillations at distinct frequencies each with their own amplitude and phase.
The most common and familiar example of frequency content in signals is probably audio
signals, and music in particular. We are all familiar with “high” musical notes and “low”
musical notes. The high notes do in fact have higher frequency content than the low notes, but
what exactly does this mean? The place to start to answer this question is to consider sinusoids.
Recall that the general expression for a sinusoid at frequency ω (or frequency f in Hertz) is
X (t) = a sin (ωt + φ) = a sin (2πf t + φ)
When considered as an audio signal, x (t) indicates the changes in air pressure on our ears as a
function of time. What is important here is the time variation of the air pressure from some
ambient value rather than the ambient value of the pressure itself. A negative value refers to
that amount below the baseline (ambient) pressure, while a positive amount refers to a pressure
higher than the baseline. So, x(t) being a sinusoid means that the air pressure on our ears varies
periodically about some ambient pressure in a manner indicated by the sinusoid. The sound we
hear in this case is called a pure tone. Pure tones often sound artificial (or electronic) rather
than musical. The frequency of the sinusoid determines the “pitch” of the tone, while the
amplitude determines the “loudness”. It turns out that the phase of the sinusoid does not affect
our perception of the tone, which may not be surprising for a pure tone, but is somewhat
surprising when we start combining sinusoids.
We can combine two sinusoids by adding the signals in the usual way.
For example,
X (t) = sin (2πt) + sin (4πt)
is a combination of a sinusoid with frequency 1 Hz and a sinusoid with frequency 2 Hz. Here
the amplitude of each sinusoid is 1 and the phase of each is 0. A plot of x(t) is shown in Figure
6.1. The “sound” created by x (t) is the combination of the two pure tones that make x (t).
Unfortunately, as we’ll discuss in more detail in Chapter XX, humans can’t hear the pure tones
that comprise the signal x(t) above since the frequencies are too low.
However, we can make a similar combination with signals at frequencies humans can hear. For
example, consider the signal
d (t) = sin (2π × 350 × t) + sin(2π × 440 × t)
Each of the two sinusoids (at frequencies 350 Hz and 440 Hz) alone corresponds to a pure tone
that can be heard by the normal human ear. Their combination, i.e., the signal d(t), makes a
very familiar sound, namely the dial tone on a standard U.S. telephone line. A plot of d(t) is
shown in Figure 6.2. Note that in this figure only 2 hundredths of a second are shown. Because
the frequencies are high, if we showed even a whole second, the signal would oscillate so many
times (350 and 440 for the constituent sinusoids) that not much useful detail would be seen.
Although the dial tone is a simple example of a sound that still sounds artificial, by combining
more sinusoids at different frequencies we can get many

other sounds. Musical notes that we find pleasing largely consist of pure tones near the pitch
of the musical note, but also contain other frequencies that give each instrument its particular
qualities. Voice and other natural sounds are also comprised of a number of pure tones.
Amazingly, all sounds can be built up out of pure tones, and likewise all-time signals can be
constructed by combining sinusoids. Similarly, starting with a general time signal, one can
break this signal down into its constituent sinusoids. How to do this and the consequences of
such constructions/decompositions is the subject of frequency domain analysis and Fourier
transforms.
MATLAB CODE:
Fs=1000; % sampling frequency
Ts=1/Fs; % Sampling Period or time step
dt=0:Ts:5-Ts; %signal Duration
f1=10;
f2=30;
f3=70;
%y=Asin(2pift+theta);
y1=10*sin(2*pi*f1*dt);
y2=10*sin(2*pi*f2*dt);
y3=10*sin(2*pi*f3*dt);
y4=y1+y2+y3;
% subplot(4,1,1);
% plot(dt,y1,'r')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y1')
% subplot(4,1,2);
% plot(dt,y2,'g')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y2')
% subplot(4,1,3);
% plot(dt,y3,'B')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y3')
% subplot(4,1,4);
% plot(dt,y4,'r')
% xlabel('Time [s]')
% ylabel('Amplitude')
% title('Y4=y1+y2+y3')
%It will be very difficult to find the frequency of y4, because it a time domain signal.
%so In order to find the frequency, we first have to know the length of time domain signal.
nfft=length(y4); %length of time domain signal
%to have a good frequency resulation in fft, the number of length of the signal must be equal
to 2 to the power of
nfft2=2^nextpow2(nfft); % length of signal in power of 2
ff=fft(y4,nfft2); % Fourier Transform, now the ff has magnitude as well as phase.
fff=ff(1:nfft2/2); % plot only 1 side of the signal
%plot(abs(fff))
%when we plot fff, we see on x-axix we have no of samples "0 to 4500", not frequency, so
we have to change this into frequency.
% Try to zoom one sample you will see the sample.
xfft=Fs*(0:nfft2/2-1)/nfft2; %xfft is the X-Axis and fff is the Y-Axis, both values must be
same in order to plot a graph
subplot(2,1,1);
plot(dt,y4,'g'); hold on
xlabel('Time [s]')
ylabel('Amplitude [V]')
title('Time Domain Signal'
subplot(2,1,2)
plot(xfft,abs(fff),'g');hold on % Magnitude plot
xlabel('Frequency [Hz]')
ylabel('Normilized Amplitude')
title('Frequency Domain Signal')

Output:

6.1. IMPLEMENTATION OF FFT & IFFT IN SIMULINK.


Output:
 TIME DOMAIN SIGNAL

 FREQUENCY DOMAIN SIGNAL (FFT)


 TIME DOMAIN SIGNAL (IFFT)

You might also like