%to compute N-point DFT of
the sequence x(n)
N=100; %length
of sequence
xn=[1,1,1];
%input sequence
xk=fft(xn,N);
magxk=abs(xk);
angxk=angle(xk);
k=0:N-1;
subplot(2,1,1);
stem(k,magxk);
xlabel('k');
ylabel('|x(k)|');
subplot(2,1,2);
stem(k,angxk);
xlabel('k');
ylabel('arg(x(k))');
L=input('length
of the sequence'); %length of the sequence
%checking for the length of
the dft
if (N<L)
error('N must be >= L')
end
x1=[xn, zeros(1,N-L)]; %appending
zeros
%computation of twiddle
factors
for k=0:1:N-1;
p=exp(-i*2*pi*n*k/N);
x2(k+1,n+1)=p
end
end
xk=x1*x2;
No comments:
Post a Comment