Professional Documents
Culture Documents
14-EE-02
Problem 1 part 1
Dn = zeros(1,101);
for n=-50:50
X=n+51;
fun=@(t) 3.*(exp((-0.2).*t)).*exp(-1i.*n.*t);
q=(1/(2*pi))*integral(fun,0,2*pi);
Dn(X) = q;
End
Problem 1 part 2
Dn = zeros(1,101);
for n=-50:50
X=n+51;
fun=@(t) 3.*(exp((-0.2).*t)).*exp(-1i.*n.*t);
q=(1/(2*pi))*integral(fun,0,2*pi);
Dn(X) = q;
end
N=-50:50;
subplot(1,2,1);
stem(N,abs(Dn));
title('Magnitude');
subplot(1,2,2);
stem(N,angle(Dn));
title('Phase');
Shazra Murtaza
14-EE-02
Problem 1 part 3
Dn = zeros(1,101);
for n=-50:50
X=n+51;
fun=@(t) (3.*(exp((-0.2).*t))).*exp(-1i.*n.*t);
q=(1/(2*pi))*integral(fun,0,2*pi);
Dn(X) = q;
end
sum=0;
T=-10:0.01:10;
for k=-50:50
Y=(Dn(k+51))*exp(1i*k*T);
sum=sum+Y;
end
Shazra Murtaza
14-EE-02
plot(T,sum);
Problem 2 part 1
Dn = zeros(1,101);
Wo=(2*pi)/12;
for n=-50:50
X=n+51;
fun=@(t) (1/(sqrt(2*pi))).*(exp((-t.^2)/2)).*exp(-1i.*n.*Wo.*t);
q=(1/12)*integral(fun,-6,6);
Dn(X) = q;
End
Shazra Murtaza
14-EE-02
Problem 2 part 2
Dn = zeros(1,101);
Wo=(2*pi)/12;
for n=-50:50
X=n+51;
fun=@(t) (1/(sqrt(2*pi))).*(exp((-t.^2)/2)).*(exp(-1i.*n.*Wo.*t));
q=(1/12)*integral(fun,-6,6);
Dn(X) = q;
end
N=-50:50;
subplot(1,2,1);
stem(N,abs(Dn));
title('Magnitude');
subplot(1,2,2);
stem(N,angle(Dn));
title('Phase');
Shazra Murtaza
14-EE-02
Problem 2 part 3
Dn = zeros(1,101);
Wo=(2*pi)/12;
for n=-50:50
X=n+51;
fun=@(t) ((1/(sqrt(2*pi))).*(exp((-t.^2)/2))).*exp(-1i.*n.*Wo.*t);
q=(1/12)*integral(fun,-6,6);
Dn(X) = q;
end
sum=0;
T=-10:0.1:10;
for k=-50:50
Y=(Dn(k+51))*exp(1i*k*T);
sum=sum+Y;
end
Shazra Murtaza
14-EE-02
plot(T,sum);
Problem 3 Part 1
Dn = zeros(1,101);
Wo =(2*pi)/2;
for n=-50:50
X=n+51;
fun1=@(t) ((t+1).*exp(-1i.*n.*Wo.*t));
fun2=@(t) ((-t+1).*exp(-1i.*n.*Wo.*t));
q=(1/2)*integral(fun1,-1,0);
p=(1/2)*integral(fun2,0,1);
Dn(X) = p+q;
end
Problem 3 Part 2
Dn = zeros(1,101);
Shazra Murtaza
14-EE-02
Wo =(2*pi)/2;
for n=-50:50
X=n+51;
fun1=@(t) (t+1).*exp(-1i.*n.*Wo.*t);
fun2=@(t) (-t+1).*exp(-1i.*n.*Wo.*t);
q=(1/2)*integral(fun1,-1,0);
p=(1/2)*integral(fun2,0,1);
Dn(X) = p+q;
end
N=-50:50;
subplot(1,2,1);
stem(N,abs(Dn));
title('Magnitude');
subplot(1,2,2);
stem(N,angle(Dn));
title('Phase');
Shazra Murtaza
14-EE-02
Problem 3 Part 3
%CTFS Coefficients of X(t)
Dn = zeros(1,101);
Wo =(2*pi)/2;
for n=-50:50
X=n+51;
fun1=@(t) ((t+1).*exp(-1i.*n.*Wo.*t));
fun2=@(t) ((-t+1).*exp(-1i.*n.*Wo.*t));
q=(1/2)*integral(fun1,-1,0);
p=(1/2)*integral(fun2,0,1);
Dn(X) = p+q;
end
%Transfer Function
Hw=zeros(1,101);
for k=-50:50
L=k+51;
fun3=@(t) (t.*exp(-1i.*k.*Wo.*t));
v=integral(fun3,0,1);
Hw(L)=v;
end
En=Dn.*Hw;
%Output Signal
sum=0;
T=-10:0.1:10;
for A=-50:50
Y=(En(A+51))*exp(1i*A*T);
sum=sum+Y;
end
subplot(1,3,1);
plot(T,sum);
subplot(1,3,2);
stem(N,abs(sum));
title('Magnitude');
subplot(1,3,3);
stem(N,angle(sum));
title('Phase');
part a
ws=20*pi;
ws=100*pi;
Ts=2*pi/ws;
t=-1:Ts:1;
x=rectpuls(t/0.5);
plot(t,x);
X=fft(x);
z=pi*Ts*X;
z=fftshift(z);
subplot(2,3,1);
Shazra Murtaza
14-EE-02
plot(t,x);
xlabel('time');
ylabel('x(t)');
subplot(2,3,2);
w=-ws/2:ws/length(z):ws/2-ws/length(z);
plot(w,abs(z));
xlabel('frequency');
ylabel('Magnitude');
title('Magnitude Spectrum')
subplot(2,2,3);
plot(w,angle(z));
xlabel('frequency');
ylabel('Phase');
title('Phase Spectrum');
subplot(2,2,4);
plot(w,z);
xlabel('frequency')
ylabel('X(w)')
title('Spectrum')
Shazra Murtaza
14-EE-02
Part b
ws=1000*pi;
Ts=2*pi/ws;
t=-1:Ts:3;
u=heaviside(t);
x=(t).*(exp(-20*t)).*u;
X=fft(x);
z=pi*Ts*X;
z=fftshift(z);
subplot(2,3,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
subplot(2,3,2);
Shazra Murtaza
14-EE-02
w=-ws/2:ws/length(z):ws/2-ws/length(z);
plot(w,abs(z));
xlabel('frequency');
ylabel('Magnitude');
title('Magnitude Spectrum')
subplot(2,2,3);
plot(w,angle(z));
xlabel('frequency');
ylabel('Phase');
title('Phase Spectrum');
subplot(2,2,4);
plot(w,z);
xlabel('frequency')
ylabel('X(w)')
title('Spectrum')
Shazra Murtaza
14-EE-02
part c
ws=20*pi;
ws=40*pi;
Ts=2*pi/ws;
t=-1:Ts:3;
u=heaviside(t);
x=((exp(-5*t)).*cos(4*pi*t).*u);
X=fft(x);
z=pi*Ts*X;
z=fftshift(z);
subplot(2,3,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
subplot(2,3,2);
w=-ws/2:ws/length(z):ws/2-ws/length(z);
plot(w,abs(z));
xlabel('frequency');
ylabel('Magnitude');
title('Magnitude Spectrum')
subplot(2,2,3);
plot(w,angle(z));
xlabel('frequency');
ylabel('Phase');
title('Phase Spectrum');
subplot(2,2,4);
plot(w,z);
xlabel('frequency')
Shazra Murtaza
14-EE-02
ylabel('X(w)')
title('Spectrum')
pard d:
ws=20*pi;
Ts=2*pi/ws;
t=-5:Ts:5;
x=exp(-(t.^2)/2);
X=fft(x);
z=pi*Ts*X;
z=fftshift(z);
subplot(2,3,1);
plot(t,x);
xlabel('time');
ylabel('x(t)');
w=-ws/2:ws/length(z):ws/2-ws/length(z);
plot(w,abs(z));
xlabel('frequency');
ylabel('Magnitude');
title('Magnitude Spectrum')
subplot(2,2,3);
plot(w,angle(z));
xlabel('frequency');
ylabel('Phase');
title('Phase Spectrum');
subplot(2,2,4);
plot(w,z);
xlabel('frequency')
ylabel('X(w)')
title('Spectrum')
Shazra Murtaza
14-EE-02