Commit 826d7fba authored by 代育津's avatar 代育津
Browse files

update

parent 7e257365
Loading
Loading
Loading
Loading
+30 −33
Original line number Diff line number Diff line
% 4.2(a)

% 4.2(b)
tau = 0.01
T = 10
N = T/tau
tau=0.01;
T=10;
N=T/tau;

t = [0:tau:T-tau]
y = exp(-2 * abs(t-5))
t=(0:tau:T-tau);
y=exp(-2 * abs(t-5));

%4.2(c)
Y = fftshift(tau*fft(y))
Y = fftshift(tau*fft(y));

%4.2(d
w = -(pi/tau)+(0:N-1)*(2*pi/(N*tau))
w = -(pi/tau)+(0:N-1)*(2*pi/(N*tau));

%4.2(e)
X = exp(j*5*w).*Y
X = exp(1i*5*w).*Y;

%4.2(f)
magnitudeX_app = abs(X)
phaseX_app = angle(X)
magnitudeX_app = abs(X);
phaseX_app = angle(X);

x = exp(-2 * abs(t))
X2 = fftshift(tau * fft(x))
magnitudeX = abs(X2)
phaseX = angle(X2)

X2 = 1 ./ (2 + 1j * w) + 1 ./ (2 - 1j * w);
magnitudeX = abs(X2);
phaseX = angle(X2);

figure;
subplot(2, 1, 1)
hold on
semilogy(w, magnitudeX_app , w, magnitudeX)
subplot(2, 1, 1);
semilogy(w, magnitudeX_app , w, magnitudeX);
legend('|X| by approximation', '|X| ', 'Location', 'northeast');
title('magnitude of X and approximation of X');
subplot(2, 1, 2)
hold on
semilogy(w, phaseX_app, w, phaseX)
subplot(2, 1, 2);
hold on;
semilogy(w, phaseX_app, w, phaseX);
legend('|X| by approximation', '|X|', 'Location', 'northeast');
title('phase of X and approximation of X');
saveas(gcf, "plots/P4_2_f_out1.png")
close
close;

%4.2(g)
magnitudeY = abs(Y)
phaseY = angle(Y)
magnitudeY = abs(Y);
phaseY = angle(Y);

figure;
subplot(2, 1, 1)
hold on
semilogy(w, magnitudeY , 'g')
semilogy(w, magnitudeX, 'b')
subplot(2, 1, 1);
semilogy(w, magnitudeY , 'g--h',w, magnitudeX_app, 'b');
legend('Y', 'X', 'Location', 'northeast');
title('magnitude of X and Y');
subplot(2, 1, 2)
hold on
semilogy(w, phaseY, 'g')
semilogy(w, phaseX, 'b')
subplot(2, 1, 2);
hold on;
semilogy(w, phaseY, 'g');
semilogy(w, phaseX, 'b');
legend('Y', 'X', 'Location', 'northeast');
title('phase of X and Y');
saveas(gcf, "plots/P4_2_f_out2.png")
close


+11 −17
Original line number Diff line number Diff line
% 4.5(a)

a1 = [1 1.5 0.5]
b1 = [1 -2]
a1 = [1 1.5 0.5];
b1 = [1 -2];

% 4.5(b)
[r1, p1] = residue(b1, a1)
[r1, p1] = residue(b1, a1);

% r1 = [6, -5]
% p1 = [-1, -0.5]
@@ -12,10 +11,10 @@ b1 = [1 -2]
% 4.5(c)

% 4.5(d)
a2 = [1 7 16 12]
b2 = [3 10 5]
a2 = [1 7 16 12];
b2 = [3 10 5];

[r2, p2] = residue(b2, a2)
[r2, p2] = residue(b2, a2);

% r2 = [2 1 -3]
% p2 = [-3 -2 -2]
@@ -24,17 +23,12 @@ b2 = [3 10 5]

% 4.5(g)

a3 = [1 -4]
b3 = [-4]
a3 = [1 0 -4];
b3 = [-4];

% 4.5(h)
[r3, p3] = residue(b3, a3)
[r3, p3] = residue(b3, a3);

% r3 = [-4]
% p3 = [4]
% r3 = [-1 1]
% p3 = [2 -2]
% 4.5(i)




   
+1 −1
Original line number Diff line number Diff line
load ctftmod.mat

% 4.6(a)
z = [dash dash dot dot]
z = [dash dash dot dot];

% 4.6(b)
figure;
+15.7 KiB (41.9 KiB)
Loading image diff...
+11 KiB (33.1 KiB)
Loading image diff...