0% found this document useful (0 votes)
37 views3 pages

Program To Compute DFT of A Given Input: % Magnitude Plot Using Inbuilt Function % Function To Find Magnitude

The document describes a program to compute the discrete Fourier transform (DFT) of an input signal. The program takes an input signal, calculates the DFT using a built-in function and custom formulas, and plots the real and imaginary components, magnitude, and phase of the DFT. It outputs the results to the command window and displays the plots in a figure window with 6 subplots showing the input signal, DFT, magnitudes and phases.

Uploaded by

Aniket Sankpal
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)
37 views3 pages

Program To Compute DFT of A Given Input: % Magnitude Plot Using Inbuilt Function % Function To Find Magnitude

The document describes a program to compute the discrete Fourier transform (DFT) of an input signal. The program takes an input signal, calculates the DFT using a built-in function and custom formulas, and plots the real and imaginary components, magnitude, and phase of the DFT. It outputs the results to the command window and displays the plots in a figure window with 6 subplots showing the input signal, DFT, magnitudes and phases.

Uploaded by

Aniket Sankpal
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

Program to compute DFT of a given input

clc; % To clear the command window..

disp('Program for computing DFT of a given input signal') x=input('\nEnter the values of input signal : '); subplot(3,2,1) stem(x) xlabel('Time') ylabel('Amplitude') title('INPUT SIGNAL') n=length(x); % function to compute DFT y=fft(x,n); disp('DFT of the input signal is : ') disp(y) subplot(3,2,2) stem(real(y),imag(y)) xlabel('Time') ylabel('Amplitude') title('DFT Of Input Signal')

% Magnitude plot using inbuilt function % Function to find magnitude m=abs(y); disp('Magnitude of DFT using inbuilt function is :') disp(m) subplot(3,2,3) stem(m) xlabel('Time')

ylabel('Amplitude') title('Magnitude plot using inbuilt function ') % Magnitude plot using formula z=sqrt(real(y).^2+imag(y).^2); disp('Magnitude of DFT using formula is :') disp(z) subplot(3,2,4) stem(z) xlabel('Time') ylabel('Amplitude') title('Magnitude plot using formula') % Phase plot using inbuilt function % Function for finding phase a=angle(y); disp('Phase angle of DFT using inbuilt function is :') disp(a) subplot(3,2,5) stem(a) xlabel('Time') ylabel('Phase angle') title('Phase plot using inbuilt function ') % Phase plot using formula b=atan2(imag(y),real(y)); disp('Phase angle of DFT using formula is :') disp(b) subplot(3,2,6) stem(b) xlabel('Time') ylabel('Phase Angle') title('Phase plot using formula ')

COMMAND WINDOW OUTPUT:Program for computing DFT of a given input signal Enter the values of input signal : [1,1,0,0] DFT of the input signal is : 2.0000 1.0000 - 1.0000i 0 Magnitude of DFT using inbuilt function is : 2.0000 1.4142 0 1.4142 Magnitude of DFT using formula is : 2.0000 1.4142 0 1.4142 Phase angle of DFT using inbuilt function is : 0 -0.7854 0 0.7854 Phase angle of DFT using formula is : 0 -0.7854 0 0.7854 FIGURE WINDOW

1.0000 + 1.0000i

You might also like