initial commit
This commit is contained in:
33
Assignment4_211/assignment4.4.m
Normal file
33
Assignment4_211/assignment4.4.m
Normal file
@@ -0,0 +1,33 @@
|
||||
clear; close all; clc;
|
||||
|
||||
N = 128;
|
||||
n = 0:N-1;
|
||||
w1 = 2*pi*0.1;
|
||||
w2 = 2*pi*0.15;
|
||||
x = cos(w1*n) + cos(w2*n);
|
||||
|
||||
% a)
|
||||
|
||||
X = fft(x);
|
||||
magX = abs(X);
|
||||
|
||||
figure;
|
||||
stem(n, magX, 'filled');
|
||||
xlabel('n');
|
||||
ylabel('|X[n]|');
|
||||
title('Magnitude Spectrum of x[n]');
|
||||
grid on;
|
||||
|
||||
% b)
|
||||
|
||||
y = hamming(N)' .* x;
|
||||
|
||||
Y = fft(y);
|
||||
magY = abs(Y);
|
||||
|
||||
figure;
|
||||
stem(n, magY, 'filled');
|
||||
xlabel('n');
|
||||
ylabel('|Y[n]|');
|
||||
title('Magnitude Spectrum of y[n]');
|
||||
grid on;
|
||||
Reference in New Issue
Block a user