0 valutazioniIl 0% ha trovato utile questo documento (0 voti)
21 visualizzazioni1 pagina
This document describes Matlab programs to calculate the 4-point discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a test sequence x(n)=1 for 1≤n≤3 and 0 elsewhere. The DFT program calculates the DFT X(k), displays it, and plots the magnitude and phase of X(k). The IDFT program takes the DFT X(k) as input, calculates the IDFT to recover the sequence x(n), and displays it.
This document describes Matlab programs to calculate the 4-point discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a test sequence x(n)=1 for 1≤n≤3 and 0 elsewhere. The DFT program calculates the DFT X(k), displays it, and plots the magnitude and phase of X(k). The IDFT program takes the DFT X(k) as input, calculates the IDFT to recover the sequence x(n), and displays it.
Copyright:
Attribution Non-Commercial (BY-NC)
Formati disponibili
Scarica in formato DOC, PDF, TXT o leggi online su Scribd
This document describes Matlab programs to calculate the 4-point discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of a test sequence x(n)=1 for 1≤n≤3 and 0 elsewhere. The DFT program calculates the DFT X(k), displays it, and plots the magnitude and phase of X(k). The IDFT program takes the DFT X(k) as input, calculates the IDFT to recover the sequence x(n), and displays it.
Copyright:
Attribution Non-Commercial (BY-NC)
Formati disponibili
Scarica in formato DOC, PDF, TXT o leggi online su Scribd
Object: Evaluate 4 point DFT of and IDFT of x(n)= 1.0<n<3; 0 elsewhere.
PROGRAMME FOR DFT:
% this matlab programme calculates the DFT of the sequence
% inputs: causal sequence x(n) % output: display of X(k) %------ next part accepts sequence x(n) --------------------------- xn= input ('enter the sequence x(n)= '); %accept sequence x(n) %------ next part calculates DFT X(k) ------------------------------ [N,M] = size(xn); %these statement determine if M~=1, %the size of xn xn=xn'; %suitable for evaluating N=M; %the DFT. here 'N' is the length end Xk = zeros(N,1); %the DFT values are initialized to zeros n = 0:N-1; %index n varies from nn to N-1 for k= 0:N-1 %this for loop implements Xk(k+1) = exp(-j*2*pi*k*n/N)*xn; % the DFT equation and calculates end disp('X(k) ='); disp(Xk); % display the DFT X(k) %------next part calculates and sketches magnitude of X(k)----------- subplot(2,1,1); %select first figure of the two in subplot k = 0:N-1; %range of k from 0 to N-1 stem(k,abs(Xk),'filled'); %sketch |X(k)| in the figure grid on; %grid in the figure ylabel('magnitude|X(k)|','color','m'); %label of y axis title('magnitude and phase of the DFT ','color','r'); %--------next part6 calculate the sketch phase of X(k)--------- subplot(2,1,2); %select second figure of vthe two in subplot k = 0:N-1; stem(k,angle(Xk),'filled'); grid on; ylabel('phase of X(k)','color','m'); xlabel('frequency index k','color','m'); %------- end of the programme--------------
PROGRAMME FOR IDFT:
% IDFT of the sequence
% input: DFT X(k) % output: display the sequence x(n) %-----next part of X(k)-------------------- Xk = input('Enter the DFT X(k)= '); %accept DFT X(k) %----next part calculates IDFT x(n)------- [N,M]=size(Xk); if M~=1, Xk = Xk.'; N=M; end xn=zeros(N,1); k=0:N-1; for n = 0:N-1 xn(n+1) = exp(j*2*pi*k*n/N)*Xk; end xn=xn/N; disp ('x(n)= '); disp(xn);