Quiz 9
Quiz 9
magnitud=zeros(1,2*N+1);
fase=-zeros(1,2*N+1);
k2=1;
for k=-N:N
if k==0;
c0=1/3;
else
ck=3/(4*k^2*(pi)^2) - (1i)/(2*k*(pi)) + (3 - 3*exp(((2*(pi)*k*(1i))/3)) +
2*(pi)*k*(1i))/(4*k^2*(pi)^2) - (3*exp((-(2*(pi)*k*(1i))/3)))/(4*k^2*(pi)^2);
end
magnitud(k2) = abs(ck);
fase(k2)= angle(ck)*(180/pi);
k2=k2+1;
end
w=w0*(-N:N);
figure(2)
subplot(2,1,1)
stem(w,magnitud)
subplot(2,1,2)
stem(w,fase)
c0=1/3;
a0=c0;
ak= zeros(1,N);
bk=zeros(1,N);
Ak=zeros(1,N);
thetak=zeros(1,N);
for k=1:N
ck=3/(4*k^2*(pi)^2) - (1i)/(2*k*(pi)) + (3 - 3*exp(((2*(pi)*k*(1i))/3)) +
2*(pi)*k*(1i))/(4*k^2*(pi)^2) - (3*exp((-(2*(pi)*k*(1i))/3)))/(4*k^2*(pi)^2);
ak(k)=2*real(ck);
bk(k)=-2*imag(ck);
temp= ak(k) - j*bk(k);
Ak(k)=abs(temp);
thetak(k)=angle(temp)*(180/pi);
end
w=w0*(0:N);
figure(3)
subplot(2,1,1)
stem(w , [a0 Ak])
subplot(2,1,2)
stem( w , [0 thetak])
x2=zeros(1,Nt);
x2=x2+a0;
for k=1: N
x2=x2 + Ak(k)*cos(k*w0*t + thetak(k)*(pi/180));
end
figure(4)
plot(t,x2)