Sei sulla pagina 1di 6

LAB TASK - I

ECE 2006 - DIGITAL SIGNAL PROCESSING


Faculty:Dr. Ashish P.
MARKS: 12
Name- Harsh Mishra
Registration Number-17BEC0599

Q1. COMPOSITE SINE WAVE AND SPECTRUM?


A.) Generate a composite sinusoidal wave containing 3 component frequencies:
10Hz, 20Hz and 30Hz. Consider the sampling frequency as 100Hz. Give its time
domain and frequency domain graphs.
Sol 1A)
Aim- To generate a composite sinusoidal wave containing 3 component
frequencies with spectrum :
Matlab code:
clc
clear all
f=100;
t=0:1/f:1;
c=4*sin(2*pi*10*t)+sin(2*pi*20*t)+sin(2*pi*30*t); % sum of 10,20 and 30
Hz sinusoids

subplot(3,1,1);
plot(t,c);
n=256;
w=0:f/n:(f-(f/n));
c=fft(c,n);
subplot(3,1,2)
plot(w,abs(c));
subplot(3,1,3);
plot(w,angle(c));
Output:

1 B.) In place of 30Hz, give (i) 70Hz signal. Analyse how does it reflect in the
spectrum. (ii) What happens if an 80Hz signal is given instead of 30Hz signal.
Sol: -
MATLAB CODE: -
clc
clear all
f = 100;
t = 0:1/f:1;
x = sin(2*pi*10*t)+sin(2*pi*20*t)+sin(2*pi*70*t); plot(t,x);
N=256;
W=0:f/N:(f-(f/N));
X=fft(x,N); plot(W,abs(X));
Output:

Inference:
Here, we observe no change in the amplitude spectrum by changing the 30 Hz
component to 70 Hz because due to aliasing, Fs - 30 = 70 and Fs - 70 = 30. In this
case, Fs/2 is only 50 Hz but the 70 Hz component goes above the maximum
allowed rate.
I B ii)
clc;
clear all;
Fs = 100;
Ts = 1/Fs;
timeSamples = 0:Ts:5-Ts;
L = 5*Fs;
sum = zeros(1,L);
n=2;
for i=1:n
sum = sum + cos(2*pi*(i*10)*timeSamples);
end
sum = sum + cos(2*pi*80*timeSamples); % adding 80 Hz sinusoid to the
sum
figure;
subplot(2,1,1);
plot(timeSamples,sum); % plotting w.r.t. time
title('Sum of sinusoids vs time');
xlabel('t (sec)');
ylabel('Amplitude');
ampSpectrum = abs(fft(sum,L))/L; % For creating Amplitude spectrum of
sum
freqs = (1:L)/5; % Creating frequency vector
subplot(2,1,2)
plot(freqs,ampSpectrum); % plotting w.r.t. frequency
title('Amp. of sum of sinusoids vs Frequency');
xlabel('f (Hz)');
ylabel('Amplitude');

Inference:
Here, the 20Hz and 80Hz components seems to combine with each other due to
aliasing as |50 - 20| = |50 - 80|
hence, giving a 2x amplitude at 20 and 80 Hz.
Q2. SYNTHESIS OF SQUARE WAVE USING FOURIER SERIES
EXPANSION
It is known that an odd square wave is given by the Fourier series expansion as
follows
𝑥(𝑡) = ∑ 4 𝑛𝜋 sin( 2𝜋𝑛𝑡 𝑇𝑜 ) ∞ 𝑛=1,3,5
Generate the above square wave in MATLAB. Consider 𝑇𝑜 = 1.
Note: The submission should contain the description of the problem, MATLAB
code and graphs.

Matlab code:
clc
clear all
f=100;
t=0:1/f:1;
t0=1;
c=0; % initializing sum
for n=1:2:100
c=c+ (4/n*pi)*sin(2*pi*n*t/t0); % Summing up

end
subplot(3,1,1);
plot(t,c); % Plotting the sum vs time
n=256;
w=0:f/n:(f-(f/n));
c=fft(c,n);
subplot(3,1,2)
plot(w,abs(c));
subplot(3,1,3);
plot(w,angle(c));

Output:
Inference:
The SYNTHESIS OF SQUARE WAVE USING FOURIER SERIES
EXPANSION was implemented in matlab and graph plotted.

Potrebbero piacerti anche