0 views

Uploaded by Sher Ejaz

- Aero Syllabus
- Linear Systems and Signals B P Lathi
- Civil Profile
- Abnormality Detection in ECG Signal Using Wavelets and Fourier Transform
- fft1
- TK Lecture 2
- 203672883-Kreider-Introduction-to-Linear-Analysis.pdf
- Hildebrand CA
- 7
- SD and Ant Tracking Carbonate
- An Ten A
- DFT
- Dsp Question Series
- Main
- QUESTION BANK FOR DIGITAL SIGNAL PROCESSING
- fft_v1_0_ds002
- werdibaji
- dft_lab1
- Hardware Implementation of a 32-Point Radix-2 FFT Architecture
- 115_yadollahi.pdf

You are on page 1of 13

YOUNIS___________________ 2019___________________

Lab #8 Fourier Series

10 /5

SHER SHAH EJAZ 212230

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.

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

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 𝑘.

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

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

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.

1.2 Lab Tasks

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.

t1=0:T/s:T;

y=A*sin((2*pi.*t1)./T);

subplot(311);

plot(t1,y,'rx')

title('Signal');

for k=-s/2:s/2

a(k+s/2+1) = integral(@(t1)

A*sin((2*pi/T)*t1).*exp(-1i*k*(2*pi/T).*t1)/T,0,T);

end

m=abs(a);

p=phase(a);

n=-s/2:s/2;

subplot(312);

stem(n,m,'kx')

title('Magnitude');

subplot(313);

stem(n,p,'bx')

title('Phase');

end

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.

function []=sher(A,T,s)

t1=0:T/s:2*T;

y=(A/2)*square(2*pi*(1/T).*t1)+(A/2);

subplot(311);

plot(t,y,'r--')

title('Signal');

for k=-s/2:s/2

a(k+s/2+1) = integral(@(t1)

((A/2).*square(2*pi*(1/T).*t1)+(A/2)).*exp(-

1i*k*(2*pi/T).*t1)/T,0,T);

end

m=abs(a);

p=phase(a);

n=-s/2:s/2;

subplot(312);

stem(n,m,'kx')

title('Magnitude');

subplot(313);

stem(n,p,'bx')

title('Phase');

end

1

……………. ……………………….

0 1 2 3 4 5

t

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).

2𝜋

𝑁 1

𝑥𝑟 (𝑡) = ∑𝑘=−𝑁 𝑎 𝑒 𝑗𝑘( 𝑇 )𝑡

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 𝑥(𝑡).

(a) function []=sher(A,T,s)

t=0:T/s:T;

y=A*sin((2*pi.*t)./T);

subplot(221);

plot(t,y,'rx')

title('Sig');

for k=-s/2:s/2

a(k+s/2+1) = integral(@(t)

A*sin((2*pi/T)*t).*exp(-1i*k*(2*pi/T).*t)/T,0,T);

end

m=abs(a);

p=phase(a);

n=-s/2:s/2;

subplot(222);

stem(n,m,'kx')

title('Mag');

subplot(223);

stem(n,p,'bx')

title('Phase angle');

x=0;

for k=-s/2:s/2

x=x+a(k+s/2+1).*exp((1i.*k*2*pi.*t)/T);

end

subplot(224)

plot(t,x,'gx')

title('Inverse F S');

end

(b)

function []=sher(A,T,s)

t=0:T/s:2*T;

y=(A/2)*square(2*pi*(1/T).*t)+(A/2);

subplot(221);

plot(t,y,'r--')

title('Sig');

for k=-s/2:s/2

a(k+s/2+1) = integral(@(t)

((A/2).*square(2*pi*(1/T).*t)+(A/2)).*exp(-

1i*k*(2*pi/T).*t)/T,0,T);

end

m=abs(a);

p=phase(a);

n=-s/2:s/2;

subplot(232);

stem(n,m,'kx')

title('Mag');

subplot(233);

stem(n,p,'bx')

title('Phase');

x=0;

for k=-s/2:s/2

x=x+a(k+s/2+1).*exp((1i.*k*2*pi.*t)/T);

end

subplot(224)

plot(t,x,'g--')

title('Inverse F S');

end

EE-232 Signals and Systems Page 12

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.

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.

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.

%HINT

y=ifft(coeff_array,N); %N is number of points in the Inverse FFT

stem(real(N*y));

- Aero SyllabusUploaded byVikram
- Linear Systems and Signals B P LathiUploaded byprashantgemini
- Civil ProfileUploaded byzilangamba_s4535
- Abnormality Detection in ECG Signal Using Wavelets and Fourier TransformUploaded byAJER JOURNAL
- fft1Uploaded bypaulim25
- TK Lecture 2Uploaded bySam Sid
- 203672883-Kreider-Introduction-to-Linear-Analysis.pdfUploaded byluisentropia
- Hildebrand CAUploaded byAngel Gallardo
- 7Uploaded bySwetha Vanam
- SD and Ant Tracking CarbonateUploaded byLita Novitasari
- An Ten AUploaded byAhsanul Hoque
- DFTUploaded byenderozyetis9518
- Dsp Question SeriesUploaded byarivurp
- MainUploaded bySteven Zhao
- QUESTION BANK FOR DIGITAL SIGNAL PROCESSINGUploaded byPRIYA RAJI
- fft_v1_0_ds002Uploaded bycnbattson
- werdibajiUploaded byAnis
- dft_lab1Uploaded byleonclarobr
- Hardware Implementation of a 32-Point Radix-2 FFT ArchitectureUploaded byLemi Foto
- 115_yadollahi.pdfUploaded bypancawawan
- fd0abb5a786fc06652a0235eff176ad5d896.pdfUploaded byhendra lam
- Fourier TransformUploaded byHesham Fadl-Allah Mohamad
- P977 5Uploaded byNithiyaa MariMuthu
- 4Uploaded bykishore
- syllabus biomedicalUploaded byS Shruti Shekhar
- FourierUploaded byArtist Recording
- Sr059210101 Mathematics IIUploaded byandhracolleges
- yucek_wcnc06Uploaded bysunitkdsp
- 32.2.zivanovicUploaded byΜέμνων Μπερδεμένος
- Adaptive ThresholdUploaded byadcmonteiro

- SM9 Specification Sheet 2945Uploaded byStephen Lichota
- Lm80-p0598-3 b Wcd9311 Audio Codec Device Spec (1)Uploaded bySaul Omar Fernandez Rojas
- Steganography based on Contourlet TransformUploaded byijcsis
- MTS-LAB-1 (1)Uploaded bypredescu_404246525
- 10.1.1.112.2812Uploaded byAbdulazeez Ayomide Adebimpe
- DIP Full File Prasenjeet 2012 13Uploaded bypratikdevikar
- Fundamentals of Spectrum AnalysisUploaded byMarius Gligor
- 49305653-Here-s-An-Easy-Way-To-TestUploaded bymaysquared
- SelectionUploaded byjjebmi
- Technical-Note 106 Narda-IDA2 Receiver and Spectrum Analyzer en (1)Uploaded by4jan1980
- Digitizing SoundUploaded byuntitled0010
- Power Amplifier ClippingUploaded byBrandy Thomas
- 1c.docxUploaded byAnkur Das
- Important Mcq- Signals and Systems_www.allexamreview.comUploaded byarijitlgsp
- DSP & ArchitectureUploaded byPriyanka Pardesi
- SG8 RF Signal Generator Data SheetUploaded byJayram Veliyath
- Yamaha Rx-V496 Rds Htr-5240 Rds SmUploaded byCarlos Otzoy
- IJETTCS-2014-02-20-092Uploaded byAnonymous vQrJlEN
- Ec6303- Ss Qb(Part - A & b)2Uploaded byMaheshwaran Mahi
- EE352 lab7Uploaded byShubham Yadav
- 3d Mic Indie User ManualUploaded bySoumya Mitra
- GPS Loop Mm12_slidesUploaded byPa PI
- Ev-dh3-pdfUploaded byBrian
- Paper 18Uploaded byJubin Jain
- hw5solUploaded byjamesyu
- Elec3505 Formula SheetUploaded bykavita4123
- onkyo_ht-r430_sm.pdfUploaded byMeujael Mendez
- mc33215bUploaded byLuis Enrique Bejarano Castillo
- Multi Rate SamplingUploaded byEngr.bilal
- decimatorUploaded byvish_vinny