0% found this document useful (0 votes)
2 views8 pages

Lab 3

The document is a laboratory script focused on the Discrete-Time Fourier Transform (DTFT) and its applications using MATLAB. It includes various sections detailing code implementations for analyzing magnitude and phase spectra, time-shifted sequences, and Fourier transforms of specific sequences. Additionally, it covers the relationship between a sequence and its derivative in the frequency domain.

Uploaded by

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

Lab 3

The document is a laboratory script focused on the Discrete-Time Fourier Transform (DTFT) and its applications using MATLAB. It includes various sections detailing code implementations for analyzing magnitude and phase spectra, time-shifted sequences, and Fourier transforms of specific sequences. Additionally, it covers the relationship between a sequence and its derivative in the frequency domain.

Uploaded by

dulguunn65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Table of Contents

Laboratory 3 All-in-One Script .............................................................................................................. 1


1. Discrete-time Fourier transform bolon ejw[n] gej yu ve? ......................................................................... 1
2-a. Code A: freqz() ashiglan magnitude/phase haruulakh ........................................................................... 1
2-b. Code B: cos dohiotoi seq + time-shifted version .................................................................................. 2
2-b (extra): num=cos + sin bolgoson version ............................................................................................ 3
2-c. Code C: DF- X(ejw) tootsooloh ....................................................................................................... 4
3. x(n)= (0.5)^n * u(n) => X(ejw) tootsooloh ............................................................................................ 5
4. X(ejw) = 1 / (1 - a*e^(-jw)) ashiglan .................................................................................................... 6
5. x(n) - iin gants uurchlult, derivative x'(n) .............................................................................................. 7

Laboratory 3 All-in-One Script


clear; close all; clc;

1. Discrete-time Fourier transform bolon ejw[n]


gej yu ve?
% tailbar:
% Discrete-Time Fourier Transform (DTFT) bol x[n]-iin Fourier huvirgalt yum.
% ejw[n] bol complex exponential basis function: exp(j*w*n)

2-a. Code A: freqz() ashiglan magnitude/phase


haruulakh
w = -pi:2*pi/255:pi; wo = 0.4*pi ; D=10;
num = [123 456 789];
h1 = freqz(num, 1, w);

figure('Name','2-a: Code A');


subplot(2,1,1); plot(w/pi,abs(h1)); grid;
title('Magnitude Spectrum of Original Sequence');
subplot(2,1,2); plot(w/pi,angle(h1)); grid;
title('Phase Spectrum of Original Sequence');

1
2-b. Code B: cos dohiotoi seq + time-shifted
version
n = 0:100;
num = cos(0.08*pi*n);
h1 = freqz(num, 1, w);
h2 = freqz([zeros(1,D) num], 1, w);

figure('Name','2-b: Code B');


subplot(2,2,1); plot(w/pi,abs(h1)); grid;
title('Magnitude Spectrum of Original Sequence');
subplot(2,2,2); plot(w/pi,abs(h2)); grid;
title('Magnitude Spectrum of Time-Shifted Sequence');
subplot(2,2,3); plot(w/pi,angle(h1)); grid;
title('Phase Spectrum of Original Sequence');
subplot(2,2,4); plot(w/pi,angle(h2)); grid;
title('Phase Spectrum of Time-Shifted Sequence');

2
2-b (extra): num=cos + sin bolgoson version
num = cos(0.08*pi*n) + 0.7*sin(0.9*pi*n);
h3 = freqz(num, 1, w);

figure('Name','2-b: Extra with sin');


plot(w/pi, abs(h3)); grid;
title('Magnitude of cos+sin Sequence');

3
2-c. Code C: DFТ-Т X(ejw) tootsooloh
n = -50:100;
x = sin(n*pi/10)+0.2*cos(n*pi/2);
k = -100:100;
w = (pi/100)*k;
X = x*(exp(-1j*pi/100)).^(n'*k);
XR = real(X); XI = imag(X);

figure('Name','2-c: Code C');


subplot(2,2,1); plot(w/pi, abs(X)); grid; axis([-1, 1, -1 20]);
xlabel('frequency in pi units'); ylabel('|X|');
title('real part of |X|');

subplot(2,2,2); plot(w/pi, XI); grid; axis([-1, 1, -10, 10]);


xlabel('frequency in pi units'); ylabel('Im(X)');
title('imaginary part of X');

subplot(2,2,3:4); plot(n,x); grid;


xlabel('sequence in time domain'); ylabel('x[n]');
title('Original Sequence');

4
3. x(n)= (0.5)^n * u(n) => X(ejw) tootsooloh
w = [0:1:500]*pi/500;
X = exp(1j*w)./(exp(1j*w)-0.5*ones(1,501));
magX = abs(X); angX = angle(X);
realX = real(X); imagX = imag(X);

figure('Name','3: Fourier Transform of (0.5)^n * u(n)');


subplot(2,2,1); plot(w/pi,magX); grid;
xlabel('frequency in pi units'); title('Magnitude Part'); ylabel('Magnitude');

subplot(2,2,3); plot(w/pi,angX); grid;


xlabel('frequency in pi units'); title('Angle Part'); ylabel('Angle');

subplot(2,2,2); plot(w/pi,realX); grid;


xlabel('frequency in pi units'); title('Real Part'); ylabel('Real');

subplot(2,2,4); plot(w/pi,imagX); grid;


xlabel('frequency in pi units'); title('Imaginary Part'); ylabel('Imag');

5
4. X(ejw) = 1 / (1 - a*e^(-jw)) ashiglan
Re, Im, Magnitude, Phase diagram baiguulakh

a = -0.5;
w = linspace(-pi, pi, 500);
X = 1./(1 - a*exp(-1j*w));

figure('Name','4: X(ejw) = 1 / (1 - a*e^-jw)');


subplot(2,2,1); plot(w/pi, real(X)); grid;
title('Re{X(e^{jw})}'); xlabel('frequency in pi units');

subplot(2,2,2); plot(w/pi, imag(X)); grid;


title('Im{X(e^{jw})}'); xlabel('frequency in pi units');

subplot(2,2,3); plot(w/pi, abs(X)); grid;


title('|X(e^{jw})|'); xlabel('frequency in pi units');

subplot(2,2,4); plot(w/pi, angle(X)); grid;


title('Phase X(e^{jw})'); xlabel('frequency in pi units');

6
5. x(n) - iin gants uurchlult, derivative x'(n)
% Jishee: x(n) = (0.5)^n*u(n), x'(n) = x(n) - x(n-1)
% Fourier huvirgaltiin khariltsaa:
% X'(ejw) = (1 - e^{-jw}) * X(ejw)

Xprime = (1 - exp(-1j*w)) .* X;

figure('Name','5: X''(e^{jw})');
plot(w/pi, abs(Xprime)); grid;
title('|X''(e^{jw})|');
xlabel('frequency in pi units'); ylabel('Magnitude');

disp('Laboratory 3 All-in-One Script done.');

Laboratory 3 All-in-One Script done.

7
Published with MATLAB® R2024b

You might also like