Lab Work 5 - Fourier Analysis of Continuous-Time Signal

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

POLITEKNIK SULTAN SALAHUDDIN ABDUL AZIZ SHAH

ELECTRICAL ENGINEERING DEPARTMENT

DEE40113 SIGNAL AND SYSTEM

LECTURER DR. MARLINA BINTI RAMLI

TYPE OF ASSESSMENT PRACTICAL WORK 5

FOURIER ANALYSIS OF CONTINUOUS-


TOPIC
TIME SIGNAL
DURATION 2 HOURS

DATE OF ASSESSMENT

NAME REGISTRATION NO.

MUHAMMAD AIMAN
IZZUDDIN BIN 08DEU22F1104
MOHD ROZI
INDIVIDUAL/
GROUP MEMBERS

MARKS /100
DEE40113 SIGNAL AND SYSTEM
PRACTICAL WORK 5 – Fourier Analysis of Continuous-Time Signal
manipulate software to analyze the DK 6 -Codified practical
CLO2 signals and systems correctly based on PLO5 engineering knowledge in a
the given procedure (P4, PLO5) recognized practice area

A. OBJECTIVE/EXPERIMENT OUTCOMES

1. To write the program to generate a basic signal.


2. To execute the program to interpret and carry out the instructions.
3. To debug the program to identify and fix errors or bugs.
4. To display the output in the specified format.

B. THEORY

Harmonic signals are transmitted undistorted from linear systems, i.e. the transmission changes the
amplitude and phase of the signal, but not the form. By assuming how a system reacts to harmonic
input signals with different frequencies, i.e. that for every harmonic input signal hn(t) we know the
amplitude and phase of the corresponding harmonic output signal H n(t). If the system changes the
amplitude of all harmonic input signals in the same manner independently of their frequency (e.g.
amplification by a factor of 2), and if all harmonic signals undergo a phase shift of m ( mN ) we
are dealing with an ideal system. From the linearity of the system, it follows immediately that a
periodic input signal f(t), which can be displayed as an infinite sum using the FOURIER, will be
transmitted undistorted through the system.

The analysis of harmonics is the process of calculating the magnitudes and phases of the fun‐
damental and high order harmonics of the periodic waveforms. The resulting series is known as
Fourier series. It establishes a relation between a function in the domain of time and a func‐ tion in
the domain of frequency. The Fourier’s theorem states that every nonsinusoidal periodic wave can
be decomposed as the sum of sine waves through the application of the Fourier series, given the
following conditions: • The integral over one period of the function is a finite value. • The function
possesses a finite number of discontinuities in a period. • The function possesses a finite number of
maxima and minima in a period. Coefficients and Fourier series. The Fourier series of a periodic
function x(t) is expressed as:

One of the terms of a Fourier series has a period equal to that of the function, f(x), and is called the
fundamental. Other terms have shortened periods that are integral submultiples of the fundamental;
these are called harmonics.
Fast Fourier Transform (FFT)

The "Fast Fourier Transform" (FFT) is an important measurement method in the science of audio
and acoustics measurement. It converts a signal into individual spectral components and thereby
provides frequency information about the signal. FFTs are used for fault analysis, quality control,
and condition monitoring of machines or systems. This article explains how an FFT works, the
relevant parameters and their effects on the measurement result.

Strictly speaking, the FFT is an optimized algorithm for the implementation of the "Discrete
Fourier Transformation" (DFT). A signal is sampled over a period of time and divided into its
frequency components. These components are single sinusoidal oscillations at distinct
frequencies each with their own amplitude and phase. This transformation is illustrated in the
following diagram. Over the time period measured, the signal contains 3 distinct dominant
frequencies.
View of a signal in the time and frequency domain

The Fast Fourier Transform is a mathematical tool that allows data captured in the time domain
to be displayed in the frequency domain. Put simply, although the vertical axis is still amplitude,
it is now plotted against frequency, rather than time, and the oscilloscope has been converted into
a spectrum analyzer. This is extremely useful for investigating distortion harmonics shown in
figure below.

The FFT is an immensely powerful tool, but it has limitations. In converting from time to the
frequency domain, the mathematics of the FFT assumes that the waveform to be analyzed repeats
itself periodically. This assumption may seem trivial, but it has major repercussions.
C. TOOLS/APPARATUS/EQUIPMENT
Computer, Software MATLAB, Scilab, Octave Online etc

D. SAFETY PROCEDURE
1. Do not plug in external devices (e.g USB thumb drive) without scanning them for computer
viruses.
2. Always back up all your important data files.

E. PROCEDURE

TASK A : PLOT THE FFT OF A SIGNAL

Execute the following command arrays below.

% define parameters
Fs = 100; % Sampling frequency
t = -0.5:1/Fs:0.5; % Time vector
L = length(t); % Signal length

X = 1/(4*sqrt(2*pi*0.01))*(exp(-t.^2/(2*0.01)));

% plot the original signal in time domain


figure, subplot(211);
plot(t,X);
title('Gaussian Pulse in Time Domain');
xlabel('Time (t)');
ylabel('X(t)');

% To use the fft function to convert the signal to the frequency domain,
% first identify a new input length that is the next power of 2 from the
% original signal length. This will pad the signal X with trailing zeros
% in order to improve the performance of fft.
n = 2^nextpow2(L);

% Convert the Gaussian pulse to the frequency domain.


Y = fft(X,n);

% Define the frequency domain and plot the unique frequencies.


f = Fs*(0:(n/2))/n;
P = abs(Y/n);

subplot(212), plot(f,P(1:n/2+1)) ;
title('Gaussian Pulse in Frequency Domain');
xlabel('Frequency (f)');
ylabel('|P(f)|');

TASK B : FREQUENCY ANALYSIS OF COMPOSITE SIGNAL

Execute the following command arrays below.

% define parameters
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector
% three signals combined together
x = sin(2*pi*50*t) + cos(2*pi*150*t) + sin(2*pi*300*t);
x1 = sin(2*pi*50*t);
x2 = cos(2*pi*150*t);
x3 = sin(2*pi*300*t);

% plot the original signal in time domain


figure, subplot(411);
plot(t,x1);
title('Composite Signal in Time Domain (1st Signal)');
xlabel('Time (t)');
ylabel('x(t)');

subplot(412), plot(t,x2);
title('Composite Signal in Time Domain (2nd Signal)');
xlabel('Time (t)');
ylabel('x1(t)');

subplot(413), plot(t,x3);
title('Composite Signal in Time Domain (3rd Signal)');
xlabel('Time (t)');
ylabel('x2(t)');

subplot(414), plot(t,x);
title('Composite Signal in Time Domain (Combined Signal)');
xlabel('Time (t)');
ylabel('x3(t)');

% calculate the fft


n = 2^nextpow2(L);

% Convert the signal to frequency domain.


Y = fft(x,n);
Y1 = fft(x1,n);
Y2 = fft(x2,n);
Y3 = fft(x3,n);

% Define the frequency domain and plot the unique frequencies.


f = Fs*(0:(n/2))/n;
P = abs(Y/n);
P1 = abs(Y1/n);
P2 = abs(Y2/n);
P3 = abs(Y3/n);

% plot the signal in frequency domain


figure, subplot(411);
plot(f,P(1:n/2+1)) ;
title('Composite Signal in Frequency Domain (Combined Signal)');
xlabel('Time (t)');
ylabel('x(t)');

subplot(412), plot(f,P1(1:n/2+1)) ;
title('Composite Signal in Frequency Domain (1st Signal)');
xlabel('Time (t)');
ylabel('x1(t)');

subplot(413), plot(f,P2(1:n/2+1)) ;
title('Composite Signal in Frequency Domain (2nd Signal)');
xlabel('Time (t)');
ylabel('x2(t)');

subplot(414), plot(f,P3(1:n/2+1)) ;
title('Composite Signal in Frequency Domain (3rd Signal)');
xlabel('Time (t)');
ylabel('x3(t)');
TASK C : FREQUENCY ANALYSIS OF CORRUPTED SIGNAL

Execute the following command arrays below.

% we are going to use the data from example 2

% same parameters as the previous one


Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1000; % Length of signal
t = (0:L-1)*T; % Time vector

% corrupt the signal using noise


x = sin(2*pi*50*t) + cos(2*pi*150*t) + sin(2*pi*300*t);
noise = randn(1,length(x));
x_noisy = x + noise;

% plot the noise and see its distribution


figure, subplot(211);
plot(noise);
title('Noise Signal');
xlabel('Time (t)');
ylabel('n(t)');
subplot(212), histogram(noise);
title('Noise Signal Distribution');

% plot the original and corrupted signal


figure, subplot(211), plot(x);
title('Composite Signal (Clean)');
xlabel('Time (t)');
ylabel('x(t)');

subplot(212), plot(x_noisy);
title('Composite Signal (Noisy)');
xlabel('Time (t)');
ylabel('x_n_o_i_s_y(t)');

% now we calculate the fft of the noisy signal


n = 2^nextpow2(L);
Ynoisy = fft(x_noisy,n);

% Define the frequency domain and plot the unique frequencies.


f = Fs*(0:(n/2))/n;
Pnoisy = abs(Ynoisy/n);

% plot the signal in frequency domain


figure, plot(f,Pnoisy(1:n/2+1)) ;
title('Noisy Signal in Frequency Domain');
xlabel('Time (t)');
ylabel('x(t)');

% based on this we can design a filter out the noise, which will be the
% subject of the next example. Save it to use later
save('filterExample.mat', 'Fs', 't', 'x', 'x_noisy');

F. RESULT/DATA

A.
B.
C.
G. DISCUSSION

In this particular session, I examine the application of Fourier analysis through MATALB
in the evaluation of the continuous time signals by considering their both time and
frequency response.

In Task A I started with a Gaussian pulse, switching to FFTaged version whereto the time
signal is transformed into the frequency one. Having chosen the value of sampling
frequency and time vector, I used MATLAB fft() function rendering possibility to display
the pulse in both time and frequency domains. This was an indication of the benefits of
Fourier analysis in revealing the constituent frequencies present in the signal and thus the
frequency characteristics of the signal.

For Task B, I constructed a signal which consisted of three frequencies, specifically 50 Hz,
150 Hz, and 300 Hz. I was able to create each frequency and together develop each one of
the attached images into time domain structure of the combination signal created. When
FFT was utilized, I examined the individual signal’s frequency response and also that of
composite signal which consisted of the three frequencies. This task proved the usefulness of
Fourier analysis when it comes to analyzing complex signals that contain different
frequencies.

Task C included the introduction of composite signals along with random noise in order to
study noise effects. I also illustrated the effect of noise on the clean signal. The signal
observed interference in particular at high frequencies as evidenced in the time and
frequency domains. The experiment was completed using FFT, at which point I understood
noise to be distributed over a range of frequencies and how that such a noise might be
removed during the filtering process.

I utilized MATLAB for the implementation and correction of the results throughout the
laboratory session. This overall makes me happier as I was given a demonstration of
Fourier Analysis and how it can be used to cut signals into pieces to see exactly what
frequencies are contained in the signals,

H. CONCLUSION
In conclusion, this lab provided valuable hands-on experience with Fourier analysis in
MATLAB, demonstrating how complex signals can be broken down into individual
frequency components. By analyzing a Gaussian pulse, a composite signal, and the effect of
noise, I gained a deeper understanding of the practical applications of the Fast Fourier
Transform (FFT) in signal processing. The ability to separate and identify frequency
elements within a signal, even in the presence of noise, highlights the importance of Fourier
analysis in revealing information that is not easily visible in the time domain. Overall, this
lab reinforced the utility of FFT as a powerful tool for examining and interpreting signals in
both theoretical and real-world scenarios.

I. REFERENCES
1. Proakis, J. G., & Manolakis, D. G. (2007). Digital Signal Processing: Principles,
Algorithms, and Applications (4th ed.). Pearson.
2. Oppenheim, A. V., Willsky, A. S., & Nawab, S. H. (1996). Signals and Systems (2nd ed.).
Prentice Hall.
3. MathWorks. (n.d.). Fourier Transforms. In MATLAB Documentation. Retrieved from
https://www.mathworks.com/help/matlab/fourier-transforms.html
4. Smith, S. W. (1997). The Scientist and Engineer's Guide to Digital Signal Processing.
California Technical Publishing.
5. Bracewell, R. N. (2000). The Fourier Transform and Its Applications (3rd ed.). McGraw-Hill
Education.
6. Van Drongelen, W. (2006). Signal Processing for Neuroscientists: An Introduction to the
Analysis of Physiological Signals. Academic Press.

Prepared by : Checked by : Verified by :

(DR. MARLINA RAMLI) (ABU BAKAR HAFIS BIN KAHAR) (NORAZLINA BINTI JAAFAR)
Head of Programme/Subject Matter Head of Department/Head of
Course Coordinator/Course Expert/Course Coordinator Programme/ Course Leader
Lecturer
Date : 2.8.2024 Date : 2.8.2024
Date : 2.8.2024
Student 1

Student 2
Score 1 2 3 4 5

Score
Aspect Weak Average Satisfactory Good Excellent

Able to write
part of the
program Able to write
Able to write
Able to write correctly but program and gives
Write Program Unable to write program without
program less than three correct output
PRACTICAL SKILL (70%)

program lecturer’s x5
incorrectly quarter of the under supervision
assistance
program under of the lecturer
supervision of
the lecturer

Unable to Executing Able to execute Able to execute Execute ALL


Execute execute program is 30% 50% program is 80% program is program
program program with successfully successfully successfully successfully x5
assistance with assistance with assistance without assistance without assistance

Unable to Able to debug Able to debug


Able to debug
Debug perform any Able to debug program 50% program 80%
ALL program
Program debugging incorrectly correctly with correctly without x4
without assistance
program assistance assistance
Able to display Able to display Able to display all
Able to display output 50% output 80% the output
Display
Output output correctly under correctly without excellently
incorrectly x2
incorrectly supervision of the supervision of without the help
the lecturer lecturer of the lecturer
Very Some of the
All important
incomplete or results have Almost of the Almost all of the
trends and data
incorrect been correctly results have results have been
comparisons have
interpretation of interpreted and been correctly correctly
been interpreted
trends and discussed; interpreted and interpreted and
Discussion correctly and
comparison of partial but discussed, only discussed, only
discussed, good x2
data indicating a incomplete minor minor
understanding of
lack of understanding improvements improvements are
results is
REPORT (30%)

understanding of results is still are needed needed


conveyed
of results evident

Accurate
Accurate statement of the
No conclusion A statement of statement of the results of lab
A statement of
was included or the results of the results of the lab indicates whether
the results is
shows little lab indicates indicates whether results support
Conclusion incomplete with
effort and whether results results support the hypothesis
little reflection x1
reflection on the support the hypothesis Possible sources
on the lab
lab hypothesis Possible sources of error and what
of error identified was learned from
the lab discussed

References 0 reference 1-2 references 3-4 references 4-5 references >5 references x1

Total 100

You might also like