0% found this document useful (0 votes)
39 views1 page

%LX Length (X) %sum 0 : All All

This MATLAB code calculates the discrete-time Fourier transform (DTFT) of the input signal x, which contains all 1s. It uses a for loop to calculate the sum from 0 to N-1 and stores the results in X. It then plots the magnitude and angle of the DTFT X against the frequency k.

Uploaded by

Akanksha Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views1 page

%LX Length (X) %sum 0 : All All

This MATLAB code calculates the discrete-time Fourier transform (DTFT) of the input signal x, which contains all 1s. It uses a for loop to calculate the sum from 0 to N-1 and stores the results in X. It then plots the magnitude and angle of the DTFT X against the frequency k.

Uploaded by

Akanksha Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

clc;

clear all;
close all;
p=1;
x=[1 1 1 1];
%lx=length(x);
lN=4;
%sum=0;
for k=0:1:lN-1;
sum=0;
for n=0:1:lN-1;
w=(2*pi*k)/lN;
y=x(n+1)*exp(-j*w*n);
sum=sum+y;
end;
X(p)=sum;
p=p+1;
end;
%w=0:0.01:2*pi;
k=0:1:lN-1;
subplot(1,2,1);
stem(k,abs(X));
xlabel('Frequency w');
ylabel('magnitude of X(w)');
title('DTFT Magnitude');

%w=0:0.01:2*pi;
k=0:1:lN-1;
subplot(1,2,2);
stem(k,angle(X));
xlabel('w');
ylabel('Angle of X(w)');
title('DTFT Angle');

You might also like