You are on page 1of 5

North South University

Course : ETE 471L


Spring 2020

Name: Ifthakharul Alam Shuvo


ID: 1530421045
SEC: 01
FINAL ASSIGNMENT
Question 1 answer:

Code:

fp=300;
p=300;
fs=500; Fs=10000;
Rp=2.5;
Rs=50;
%calculate edge frequencies
Wp= 2*fp/Fs;
Ws= 2*fs/Fs;
[N,Wn]=buttord(Wp, Ws, Rp, Rs)
%Here N is the order of the filter and Wn is the cutoff
frequency, add the lines
[b,a]=butter(N,Wn)
freqz(b)
legend('Name:Ifthakharul Alam Shuvo')
title('ID:1530421045')

Figure:
Ques 2 answer:
code:
Fs = 150; % Sampling frequency
t = 0:1/Fs:1; % Time vector of 1 second
f = 15; % Create a sine wave of f Hz.
x1 = sin(2*pi*t*f);
x2 = (cos(2*pi*t*f)-pi/3);
nfft = 1024; % Length of FFT
% Take fft, padding with zeros so that length(X) is equal to
nfft
X1 = fft(x1,nfft);
X2 = fft(x2,nfft);

X1 = X1(1:nfft);
X2 = X2(1:nfft);
% Take the magnitude of fft of x
mx1 = abs(X1);
mx2 = abs(X2);
% Frequency vector
f = (0:nfft-1)*Fs/nfft;
% Generate the plot, title and labels. subplot(211);
subplot(411)
stem(t,x1);
title('sin Wave Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(412);
plot(f,mx1);
title('Power Spectrum of a sin Wave');
xlabel('Frequency (Hz)');
ylabel('Power');
subplot(413)
stem(t,x2);
title('cos Wave Signal');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(414);
plot(f,mx2);
title('Power Spectrum of a cos Wave');
xlabel('Frequency (Hz)');
ylabel('Power');
Figure:

Yes here we can see difference between the power spectrum.There is a spike at the beginning
and end of the cos power spectrum and there is no spike in sin power spectrum.And athe
amplitude of sin wave is larger than the cos wave.

Question 3 answer
a) length(x): It returns the size of the longest dimension of X.
b) fft(x): It computes the discrete Fourier transform (DFT) of x using a fast Fourier
transform (FFT) algorithm.
c) iztrans(f) : It returns the Inverse Z-Transform of f.
d) heaviside(t): It evaluates the heaviside step function at t also known as the unit step
function.
e) sort(A): It sorts the elements of A in ascending order.

You might also like