title: Fourier Transform (DTFT, CTFT) in Matlab
body: <p>I have to compute Fourier Transform and Inverse Fourier Transform for a signal and plot its graphs (magnitude and phase).</p>
  
  <p><img src="https://i.stack.imgur.com/qfVBS.png" alt="enter image description here"></p>
  
  <p>How to do this in Matlab? As I know Matlab provides built in function <code>fft</code> which computes DFT and probably it is possible to convert results from DFT to DTFT. I found function that get DTFT using <code>fft</code> inside.</p>
  
  <pre><code>function [H, W] = dtft(h, N)
  %DTFT   calculate DTFT at N equally spaced frequencies
  %----
  %   Usage:   [H, W] = dtft(h, N)
  %
  %      h : finite-length input vector, whose length is L
  %      N : number of frequencies for evaluation over [-pi,pi)
  %              ==&gt; constraint: N &gt;= L 
  %      H : DTFT values (complex)
  %      W : (2nd output) vector of freqs where DTFT is computed
  
  %---------------------------------------------------------------
  % copyright 1994, by C.S. Burrus, J.H. McClellan, A.V. Oppenheim,
  % T.W. Parks, R.W. Schafer, &amp; H.W. Schussler.  For use with the book
  % "Computer-Based Exercises for Signal Processing Using MATLAB"
  % (Prentice-Hall, 1994).
  %---------------------------------------------------------------
  
  N = fix(N);
  L = length(h);  h = h(:);  %&lt;-- for vectors ONLY !!!
  if( N &lt; L )
     error('DTFT: # data samples cannot exceed # freq samples')
  end;
  W = (2 * pi / N) * (0:(N-1))';
  mid = ceil(N/2) + 1;
  W(mid:N) = W(mid:N) - 2 * pi;   % &lt;--- move [pi,2pi) to [-pi,0)
  W = fftshift(W);
  H = fftshift(fft(h,N));  %&lt;--- move negative freq components
  end
  </code></pre>
  
  <p>Could you please help me to change this function to get IDTFT? Or maybe someone has other similar functions to do this task.</p>