0% found this document useful (0 votes)
7 views3 pages

DSP Lab: Cosine Wave Analysis

The document describes a digital signal processing lab experiment involving filtering of sine waves. Five sine waves with frequencies between 10Hz and 1300Hz are summed to create a signal. This signal is then lowpass filtered with a cutoff frequency of 500Hz (half the sampling frequency) and the time domain waveform and magnitude spectrum are plotted. In a second part, four sine waves between 100Hz and 400Hz are summed and bandpass filtered between 200Hz and 300Hz before similarly plotting the time domain and magnitude spectra.

Uploaded by

parul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

DSP Lab: Cosine Wave Analysis

The document describes a digital signal processing lab experiment involving filtering of sine waves. Five sine waves with frequencies between 10Hz and 1300Hz are summed to create a signal. This signal is then lowpass filtered with a cutoff frequency of 500Hz (half the sampling frequency) and the time domain waveform and magnitude spectrum are plotted. In a second part, four sine waves between 100Hz and 400Hz are summed and bandpass filtered between 200Hz and 300Hz before similarly plotting the time domain and magnitude spectra.

Uploaded by

parul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DSP LAB-7

Parul
2021phxp0026p
1.
Fs = 1000;
fpass=Fs/2;
dt = 1/Fs;
t = (0:dt:1);
%%Sine wave:
Fc1 = 10;
Fc2 = 200;
Fc3 = 2450;
Fc4 = 1250;
Fc5 = 1300;
x1 = 2*cos(2*pi*Fc1*t);
x2 = 2*cos(2*pi*Fc2*t);
x3 = 2*cos(2*pi*Fc3*t);
x4 = 2*cos(2*pi*Fc4*t);
x5 = 2*cos(2*pi*Fc5*t);
y=x2+x1+x3+x4+x5;
z= lowpass(y,fpass,Fs);
zmag=abs(fft(z));
N=length(z);
freq=0:Fs/N:Fs*(N-1)/N;
subplot(3,1,3);
stem(freq,zmag); %Plotting the Magnitude Spectrum after Normalization
xlabel('Frequency (Hz)');
ylabel('Magnitude Spectrum');
title('FFT Magnitude response')
% Plot the signal versus time:
subplot(3,1,1)
plot(t,y);
xlabel('time'); ylabel('amplitude'); title('Signal versus Time');
subplot(3,1,2)
plot(t,z);
xlabel('time'); ylabel('amplitude'); title('filtered Signal versus Time');
sprintf("Specified passband frequency is beyond the Nyquist range so signal has
been filtered with an allpass filter.")
2
Fs = 1000;
dt = 1/Fs;
t = (0:dt:1);
%%Sine wave:
Fc1 = 100;
Fc2 = 200;
Fc3 = 300;
Fc4 = 400;
x1 = 2*cos(2*pi*Fc1*t);
x2 = 2*cos(2*pi*Fc2*t);
x3 = 2*cos(2*pi*Fc3*t);
x4 = 2*cos(2*pi*Fc4*t);
y=x2+x1+x3+x4;
subplot(4,2,1);
plot(t,y);

ymag=abs(fft(y));
N=length(y);
freq=0:Fs/N:Fs*(N-1)/N;
subplot(4,2,3);
plot(freq,ymag);
xlabel('freq in hz');
ylabel('amplitude');
title('original')
z= bandpass(y,[200 300],Fs)
subplot(4,2,2)
plot(t,y,t,z,'linewidth',1.5);
title('Filtered Waveforms');
xlabel('Time (s)');
legend('Original Noisy Signal','Filtered Signal');
zmag=abs(fft(z));
N=length(z);
freq=0:Fs/N:Fs*(N-1)/N;
subplot(4,2,4);
plot(freq,zmag); %Plotting the Magnitude Spectrum after Normalization
xlabel('Frequency (Hz)');
ylabel('Magnitude Spectrum');
title('FFT Magnitude response')

You might also like