You are on page 1of 3

Signal & System [EE-320] 2019-EE-049

LAB 10
OBJECT: UNDERSTANDING FOURIER SERIES USING MATLAB.

Task 1: Generate a Square wave by using trigonometric form of Fourier Series for up to seven
harmonics.

CODE:

f=1
w=2*pi*f
t=0:0.01:1
y=sin(w*t)+(1/3)*sin(3*w*t)+(1/5)*sin(5*w*t)+(1/7)*sin(7*w*t)+(1/9)*sin(9*w*t)+(1/11)*sin(11*w*t)
+(1/13)*sin(13*w*t)
plot(t,y)

OUTPUT:

DEPARTMENT OF ELECTRONIC ENGINEERING P a g e | 61


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
Signal & System [EE-320] 2019-EE-049

TASK 2: Generate a Sawtooth wave by using trigonometric form of Fourier series for up to seven
harmonics.

CODE:

f=1
w=2*pi*f
t=0:0.01:1
y=sin(w*t)+(1/2)*sin(2*w*t)+(1/3)*sin(3*w*t)+(1/4)*sin(4*w*t)+(1/5)*sin(5*w*t)+(1/6)*sin(6*w*t)
+(1/7)*sin(7*w*t)
plot(t,y)

OUTPUT:

TASK 3: Generate a Triangular wave by using trigonometric form of Fourier form up to seven
harmonics.

CODE:

f=1
w=2*pi*f
t=0:0.01:1
y=sin(w*t).^2+(1/9)*sin(3*w*t).^2+(1/25)*sin(5*w*t).^2+(1/49)*sin(7*w*t).^2+(1/81)*sin(9*w*t).^2+
(1/121)*sin(11*w*t).^2+(1/169)*sin(13*w*t).^2;
plot(t,y)

DEPARTMENT OF ELECTRONIC ENGINEERING P a g e | 62


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
Signal & System [EE-320] 2019-EE-049

OUTPUT

TASK 4: Write a Matlab program which generate square wave by using fourier series for n=500 no
of harmonics.

CODE:
a=0;
f=1
w=2*pi*f
t=0:0.01:1
for n=1:2:500;
a=a+(1/n)*sin(n*w*t)
end
plot(t,a)

OUTPUT

DEPARTMENT OF ELECTRONIC ENGINEERING P a g e | 63


SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY

You might also like