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

SNS___Lab__Report__7(Fourier)

The document outlines Lab 7 for the EE-232 Signals and Systems course, focusing on Fourier Series calculations for continuous and discrete time signals. It includes objectives, lab instructions, tasks, and MATLAB demos for analyzing and reconstructing signals. The lab emphasizes understanding signal decomposition and synthesis through practical applications and visualization techniques.

Uploaded by

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

SNS___Lab__Report__7(Fourier)

The document outlines Lab 7 for the EE-232 Signals and Systems course, focusing on Fourier Series calculations for continuous and discrete time signals. It includes objectives, lab instructions, tasks, and MATLAB demos for analyzing and reconstructing signals. The lab emphasizes understanding signal decomposition and synthesis through practical applications and visualization techniques.

Uploaded by

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

Department of Electrical Engineering

Faculty Member: Dr. Abdullah Mughees Dated: 20//11//20204

Section: A Semester: 5th

EE-232 : Signals and Systems


Lab 7 : Fourier Series

PLO5 –CLO3 PLO5- PLO8- PLO9-CLO5


CLO3 CLO4
Name Reg. No Viva / Quiz / Analysis Modern Ethics and Individual
Lab of data in Tool Usage Safety and Team
Performance Lab Work
Report

5 Marks 5 Marks 5 Marks 5 Marks 5 Marks


Manahil Ahmad 407744

Hafiza Adeela Arif 420111

EE-232 Signals and Systems Page 1


Lab7: Fourier Series

Objectives
The goal of this laboratory is to be able to calculate the fourier series of approximately continuous time and
discrete time signals and plot the real part of the spectrum / Fourier series coefficients.

 MATLAB Demos on Fourier series


 Fourier Series Calculation of Discrete Time Signals
 Inverse Fourier Series Calculation given Fourier Series Coefficients
 Determine Frequency Response of an LTI Causal System

Lab Instructions
 This lab activity comprises of three parts: Pre-lab, Lab Exercises, and Post-Lab Viva session.
 The Pre-lab tasks should be completed before coming to the lab. The reports are to be submitted on
LMS.
 The students should perform and demonstrate each lab task separately for step-wise evaluation
 Only those tasks that completed during the allocated lab time will be credited to the students.
Students are however encouraged to practice on their own in spare time for enhancing their skills.
Lab Report Instructions
All questions should be answered precisely to get maximum credit. Lab report must ensure following items:
 Lab objectives
 MATLAB codes
 Results (graphs/tables) duly commented and discussed
 Conclusion

EE-232 Signals and Systems Page 2


Fourier Series of Continuous Time and Discrete Time Signals

1.1 Pre-Lab

1.1.1 Introduction

CTFS
2𝜋
For a CT signal 𝑥(𝑡) with fundamental period 𝑇 and fundamental frequency 𝑤0 = , the CTFS synthesis
𝑇
and analysis equations are given by (1) and (2), respectively.
2𝜋
𝑗𝑘( )𝑡
𝑥(𝑡) = ∑∞
𝑘=−∞ 𝑎𝑘 𝑒
𝑇 (1)
2𝜋
1
𝑎𝑘 = 𝑇 ∫𝑇 𝑥(𝑡)𝑒 −𝑗𝑘( 𝑇 )𝑡 𝑑𝑡 (2)

DTFS

For a DT signal 𝑥[𝑛] with fundamental period 𝑁, the DTFS synthesis and analysis equations are given by
(3) and (4), respectively.
2𝜋
𝑥[𝑛] = ∑𝑘=<𝑁> 𝑎𝑘 𝑒 𝑗𝑘( 𝑁 )𝑛 (3)
2𝜋
1
𝑎𝑘 = 𝑁 ∑𝑛=<𝑁> 𝑥[𝑛]𝑒 −𝑗𝑘( 𝑁 )𝑛 (4)

Remember that 𝑥[𝑛] has period 𝑁, so that the summation in (4) can be replaced with a sum over any 𝑁
consecutive values of 𝑛. Similarly, 𝑎𝑘 is periodic in 𝑘 with period 𝑁 so that the summation in (3) can be
replaced with a sum over any 𝑁 consecutive values of 𝑘.

EE-232 Signals and Systems Page 3


1.1.2 Fseriesdemo and sinesum2 Demo:
These demos concentrate on the use of MATLAB GUI for Fourier series.

 fseriesdemo: FourierSeriesDemo is a GUI that shows Fourier Series synthesis for different number
of Fourier coefficients. Different signals can be selected: square wave, sawtooth, triangle and
rectified sinusoids.
 sinesum demo: Sinesum demo helps us to take the sum of sinusoids to create more complex signals.

You have been provided the zip files for both. Extract them to the MATLAB working directory or extract
them to any directory of choice and include the path in MATLAB. We can run the demos by writing the
following commands on the Command Window.

>> fseriesdemo

EE-232 Signals and Systems Page 4


Pre Lab Task 1

Your task is to create a sawtooth waveform with T=10sec and increase the number of Fourier coefficients.
Observe and state the significance of increasing number of coefficients. Also provide the screenshot.

>> sinesum2

EE-232 Signals and Systems Page 5


Pre Lab Task 2

Your task is to increase the number of harmonics to 5. Change the amplitude of these harmonics. Explain
the effect of changing the number of harmonics in the sinesum demo. Also provide the screenshot.

EE-232 Signals and Systems Page 6


1.2 Lab Tasks

1.2.1 Lab Task 1: CTFS

1.2.1.1 Fourier series of a CT Sinusoid


Write a function that will generate a single sinusoid 𝑥(𝑡) = 𝐴 sin(𝑤𝑡). 𝐴 = 3 and time period 𝑇 = .01.
Choose an appropriate value of ‘time_increment/sampling time’ during the generation of signal.
t=0:time_increment:T

Determine the Fourier series coefficients and plot the magnitude and phase of the fourier series coefficients
NOTE:
 For calculating the fourier series coefficients use (1).
 Note that (1) involves solving an integration. Use MATLAB built in function integral() to
numerically evaluate the integral. For example, for a value of 𝑘 = 4, the function will be evaluated
as
a = integral(@(z) 𝐴 ∗ sin((2 ∗ 𝑝𝑖/𝑇) ∗ 𝑧).*exp(-j*4*(2*pi/T)*z)/T,0,T)
 Above code will return the value of the 4th CTFS coefficient. For remaining coefficients, replace 4
and follow similar procedure. You may use a loop to iterate over values of 𝑘.
 Add the figures of both the time domain and frequency domain representation of the singals with
appropriate axes, labels and titles.
Code:

EE-232 Signals and Systems Page 7


Explanation:

The function specified by this code generates a sine wave with specified amplitude (A) and period (T), plots
the wave, and then calculates and displays its Fourier series coefficients, magnitude spectrum, and phase
spectrum.This function provides a visual representation of the decomposition of a sine wave into its
constituent frequency components, offering insights into the harmonic content of the signal. Adjustments to
parameters and plotting options can be made to tailor the analysis to specific needs.

Result:

EE-232 Signals and Systems Page 8


1.2.1.2 Fourier Series of a CT Rectangular wave
Assume a rectangular wave as shown below. Using a similar approach outlined in the previous task, obtain
the CTFS representation of the rectangular wave. Plot the magnitude and phase of the fourier series
coefficients with appropriate axes, labels and titles.

……………. ……………………….
0 1 2 3 4 5
t

Code:

EE-232 Signals and Systems Page 9


Explanation:
This MATLAB function analyzes a square wave signal by first generating it with user-specified amplitude,
period, and the number of harmonics. The square wave is plotted in the first subplot. Fourier series
coefficients are then computed using a loop and integral formula for a range of harmonics. This function
provides a comprehensive visualization of the frequency components of a square wave, allowing users to
adjust parameters for specific analyses.

Result:

EE-232 Signals and Systems Page 10


1.2.2 Lab task 2:

1.2.2.1 Inverse CT Fourier Series Calculation

For the signals in Tasks 1.2.1.1 and 1.2.1.2, reconstruct the signal using the obtained FS coefficients 𝑎𝑘 . The
CT signal can be generated from the FS coefficients 𝑎𝑘 using (1).
𝑁1
2𝜋
𝑥𝑟 (𝑡) = ∑ 𝑎𝑘 𝑒 𝑗𝑘( 𝑇 )𝑡
𝑘=−𝑁1
Choose an appropriate value of ‘time_increment/sampling time’ during the generation of complex
exponential signal. Plot the reconstructed signal 𝑥𝑟 (𝑡) for 𝑁1 = 3, 10, 50 . Compare with original signal
𝑥(𝑡).
Use of fft and ifft

MATLAB contains efficient routines for computing CTFS and DTFS. If x is an N-point vector for the period
0 ≤ n ≤ N - 1, then the DTFS of x[n]can be computed by ak=(l/N)*fft(x), where the N-point vector a contains
ak for 0 ≤ k ≤ N - 1. The function fft is simply an efficient implementation of (2) scaled by N. Thus,
DTFS can by computed by typing ak=(l/N)*fft(x). The function will return both real and imaginary parts
of the DTFS coefficients.

Given a vector containing the DTFS coefficients ak for 0 ≤ k ≤ N - 1, the function ifft can be used to construct
a vector x containing x[n] for 0 ≤ n ≤ N – 1 as x=N*ifft (a). The function ifft is an efficient realization of the
DTFS synthesis equation, scaled by 1/N.

 Choose an appropriate value of ‘time_increment’ during the generation of cosine function.


for n=0:time_increment:T
%Generate Cosine Wave
 % Hint for calculating the fourier series and displaying its real part
L=length(signal);
y=real(fft(signal,L))/L;
stem(y);
In case of the given signal t and T are being used in place of n and N because the increment between 0 and
T will have small increments than 1.

Using the function ‘ifft’ and knowledge of FS coefficents of a Cosine waveform determine the signal x[n].
For the lab report plot both the fourier coefficients and time domain signal.

Now assuming that the DTFT was N Point DTFT or FFT. Then the fourier Series Coefficients of x[n]
= cos (pi/4) n will have impulses at locations k and N-k.

ωk = 2 pi k /N If ωk = pi/4 Then k = N/8 Where N is the N point DTFT or FFT. Assuming that N =1024
locations k and N-k can be calculated. So the coeff_array will be an array of size N with fourier series
coefficients of a cosine waveform at locations k and N-k.

EE-232 Signals and Systems Page 11


Sine Wave:

Code:

Explanation:

A sine wave was generated and reconstructed using Fourier coefficients through an Inverse Fourier Transform.
Harmonic contributions were iteratively added to rebuild the original signal, showing the role of each component.

EE-232 Signals and Systems Page 12


N Result
3

10

50

EE-232 Signals and Systems Page 13


Square Wave:

Code:

Explanation:

A square wave was analyzed and reconstructed using Fourier series coefficients. The iterative process highlighted
how harmonics contribute to rebuilding the wave.

EE-232 Signals and Systems Page 14


N Result
3

10

50

EE-232 Signals and Systems Page 15


Conclusion:

This lab focused on analyzing and reconstructing periodic signals using Fourier series and transforms. Sine
and square waves were decomposed into their harmonic components, illustrating the frequency domain
representation. The iterative reconstruction process demonstrated how signals can be synthesized from
Fourier coefficients. MATLAB functions and tools were effectively used for visualization and analysis.
These techniques provide a deeper understanding of signal decomposition and synthesis, with practical
applications in engineering.

EE-232 Signals and Systems Page 16

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy