Write a MATLAB function that can compute the DFT of a given
Write a MATLAB function that can compute the DFT of a given sequence. Do not use the DFT/FFT functions provided by MATLAB. Describe how your function can be called. Provide a list of your code. Describe in detail any steps you have taken to improve the functionality and performance of your DFT function. Verify that your DFT function is correct by using it to compute the DFT of three different signals of your choice and comparing the results with closed- form expressions you obtain through derivation.
Solution
function X=dft1(x)
n=size(x);
w=0:0.1:2*pi;
X=zeros(1,size(w));
for k=0:n-1
X=X+x(k+1).*exp(-1i.*w.*k);
end
>> dft1(1)
ans =
Columns 1 through 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 16 through 30
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 31 through 45
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 46 through 60
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Columns 61 through 63
1 1 1
