% This file was automatically created from the m-file 
% "m2tex.m" written by USL. 
% The fontencoding in this file is UTF-8. 
%  
% You will need to include the following two packages in 
% your LaTeX-Main-File. 
%  
% \usepackage{color} 
% \usepackage{fancyvrb} 
%  
% It is advised to use the following option for Inputenc 
% \usepackage[utf8]{inputenc} 
%  
  
% definition of matlab colors: 
\definecolor{mblue}{rgb}{0,0,1} 
\definecolor{mgreen}{rgb}{0.13333,0.5451,0.13333} 
\definecolor{mred}{rgb}{0.62745,0.12549,0.94118} 
\definecolor{mgrey}{rgb}{0.5,0.5,0.5} 
\definecolor{mdarkgrey}{rgb}{0.25,0.25,0.25} 
  
\DefineShortVerb[fontfamily=courier,fontseries=m]{\$} 
\DefineShortVerb[fontfamily=courier,fontseries=b]{\#} 
  
\noindent                                                               
 \hspace*{-1.6em}{\scriptsize 1}$  $\color{mgrey}#%% Hilbert transformer#\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 2}$  clear, $\color{mdarkgrey}$clc, close all$\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 3}$  $\\
 \hspace*{-1.6em}{\scriptsize 4}$  $\color{mgrey}$% Define parameters$\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 5}$  L = 31;$\\
 \hspace*{-1.6em}{\scriptsize 6}$  M = L -1;$\\
 \hspace*{-1.6em}{\scriptsize 7}$  $\\
 \hspace*{-1.6em}{\scriptsize 8}$  $\color{mgrey}#%% a) Window method#\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 9}$  n = -M/2:M/2;$\\
 \hspace*{-2em}{\scriptsize 10}$  hd = 2/pi*((sin(pi*n/2)).^2)./n;$\\
 \hspace*{-2em}{\scriptsize 11}$  hd(n == 0) = 0; $\color{mgrey}$% enforce value at 0$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 12}$  $\\
 \hspace*{-2em}{\scriptsize 13}$  $\color{mgrey}$% window by Hamming window$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 14}$  hwin = hd.*hamming(M+1).';$\\
 \hspace*{-2em}{\scriptsize 15}$  $\\
 \hspace*{-2em}{\scriptsize 16}$  [Hwin, w] = freqz(hwin, 1, $\color{mdarkgrey}$'whole'$\color{black}$);$\\
 \hspace*{-2em}{\scriptsize 17}$  $\\
 \hspace*{-2em}{\scriptsize 18}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 19}$  plot(w/pi, abs(Hwin).^2, $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 20}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 21}$  ylabel($\color{mdarkgrey}$'Magnitude'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 22}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_win_mag'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 23}$  $\\
 \hspace*{-2em}{\scriptsize 24}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 25}$  plot(w/pi, unwrap(angle(Hwin)), $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 26}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 27}$  ylabel($\color{mdarkgrey}$'Magnitude'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 28}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_win_phase'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 29}$  $\\
 \hspace*{-2em}{\scriptsize 30}$  $\color{mgrey}#%% b) Parks-McClellan method#\color{black}$$\\
 \hspace*{-2em}{\scriptsize 31}$  hpm = firpm(M, [0.1 0.9], [1 1], $\color{mdarkgrey}$'hilbert'$\color{black}$);$\\
 \hspace*{-2em}{\scriptsize 32}$  figure, $\color{mdarkgrey}$freqz(hpm, 1)$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 33}$  $\\
 \hspace*{-2em}{\scriptsize 34}$  [Hpm, w] = freqz(hpm, 1, $\color{mdarkgrey}$'whole'$\color{black}$);$\\
 \hspace*{-2em}{\scriptsize 35}$  $\\
 \hspace*{-2em}{\scriptsize 36}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 37}$  plot(w/pi, abs(Hpm).^2, $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 38}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 39}$  ylabel($\color{mdarkgrey}$'Magnitude'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 40}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_pm_mag'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 41}$  $\\
 \hspace*{-2em}{\scriptsize 42}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 43}$  plot(w/pi, unwrap(angle(Hpm)), $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 44}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 45}$  ylabel($\color{mdarkgrey}$'Magnitude'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 46}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_pm_phase'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 47}$  $\\
 \hspace*{-2em}{\scriptsize 48}$  $\color{mgrey}#%% c) Least-squares method#\color{black}$$\\
 \hspace*{-2em}{\scriptsize 49}$  hls = firls(M, [0.1 0.9], [1 1], $\color{mdarkgrey}$'hilbert'$\color{black}$);$\\
 \hspace*{-2em}{\scriptsize 50}$  $\\
 \hspace*{-2em}{\scriptsize 51}$  [Hls, w] = freqz(hls, 1, $\color{mdarkgrey}$'whole'$\color{black}$);$\\
 \hspace*{-2em}{\scriptsize 52}$  $\\
 \hspace*{-2em}{\scriptsize 53}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 54}$  plot(w/pi, abs(Hls).^2, $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 55}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 56}$  ylabel($\color{mdarkgrey}$'Magnitude'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 57}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_ls_mag'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 58}$  $\\
 \hspace*{-2em}{\scriptsize 59}$  figure, $\color{mdarkgrey}$box on$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 60}$  plot(w/pi, unwrap(angle(Hls)), $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 61}$  xlabel($\color{mdarkgrey}$'\omega/\pi'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 62}$  ylabel($\color{mdarkgrey}$'Phase (rad)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 63}$  saveas(gca, $\color{mdarkgrey}$'../figs/hilbert_ls_phase'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\ 
  
\UndefineShortVerb{\$} 
\UndefineShortVerb{\#}