% 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}#%% Problem 6: Frequency modulation#\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 2}$  $\color{mgrey}#%% a)#\color{black}$$\\
 \hspace*{-1.6em}{\scriptsize 3}$  t = linspace(0,4);$\\
 \hspace*{-1.6em}{\scriptsize 4}$  Wc = 2*pi*1e3;$\\
 \hspace*{-1.6em}{\scriptsize 5}$  Wm = 2*pi;$\\
 \hspace*{-1.6em}{\scriptsize 6}$  $\\
 \hspace*{-1.6em}{\scriptsize 7}$  Wi = @(beta, t) Wc + beta*Wm*cos(Wm*t);$\\
 \hspace*{-1.6em}{\scriptsize 8}$  $\\
 \hspace*{-1.6em}{\scriptsize 9}$  figure$\\
 \hspace*{-2em}{\scriptsize 10}$  subplot(211)$\\
 \hspace*{-2em}{\scriptsize 11}$  plot(t, Wi(0.2, t)/(2*pi), $\color{mdarkgrey}$'k'$\color{black}$, $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2);$\\
 \hspace*{-2em}{\scriptsize 12}$  xlabel($\color{mdarkgrey}$'t (s)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12);$\\
 \hspace*{-2em}{\scriptsize 13}$  ylabel($\color{mdarkgrey}$'\Omega_i/2\pi (Hz)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12);$\\
 \hspace*{-2em}{\scriptsize 14}$  legend($\color{mdarkgrey}$'\beta = 0.2'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 15}$  $\\
 \hspace*{-2em}{\scriptsize 16}$  subplot(212)$\\
 \hspace*{-2em}{\scriptsize 17}$  plot(t, Wi(500, t)/(2*pi), $\color{mdarkgrey}$'k'$\color{black}$, $\color{mdarkgrey}$'LineWidth'$\color{black}$, 2)$\\
 \hspace*{-2em}{\scriptsize 18}$  xlabel($\color{mdarkgrey}$'t (s)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12);$\\
 \hspace*{-2em}{\scriptsize 19}$  ylabel($\color{mdarkgrey}$'\Omega_i/2\pi (Hz)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12);$\\
 \hspace*{-2em}{\scriptsize 20}$  legend($\color{mdarkgrey}$'\beta = 500'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 21}$  saveas(gca, $\color{mdarkgrey}$'../figs/hw6_fm_a'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 22}$  $\\
 \hspace*{-2em}{\scriptsize 23}$  $\color{mgrey}#%% d)#\color{black}$$\\
 \hspace*{-2em}{\scriptsize 24}$  beta = 0.2;$\\
 \hspace*{-2em}{\scriptsize 25}$  N = 32768;$\\
 \hspace*{-2em}{\scriptsize 26}$  n = 0:N-1;$\\
 \hspace*{-2em}{\scriptsize 27}$  $\color{mgrey}$% $\color{black}$$\\
 \hspace*{-2em}{\scriptsize 28}$  x = cos(pi/4*n) - beta*sin(pi/4e3*n).*sin(pi/4*n);$\\
 \hspace*{-2em}{\scriptsize 29}$  $\\
 \hspace*{-2em}{\scriptsize 30}$  $\color{mgrey}$% soundsc(x)$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 31}$  $\\
 \hspace*{-2em}{\scriptsize 32}$  $\color{mgrey}$% (i)$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 33}$  dt = 1/8e3;$\\
 \hspace*{-2em}{\scriptsize 34}$  df = 1/(N*dt);$\\
 \hspace*{-2em}{\scriptsize 35}$  f = -1/(2*dt):df:1/(2*dt)-df;$\\
 \hspace*{-2em}{\scriptsize 36}$  X = fftshift(fft(x, N)/N);$\\
 \hspace*{-2em}{\scriptsize 37}$  $\\
 \hspace*{-2em}{\scriptsize 38}$  figure$\\
 \hspace*{-2em}{\scriptsize 39}$  plot(f, abs(X), $\color{mdarkgrey}$'k'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 40}$  ylabel($\color{mdarkgrey}$'|X(j\Omega)|'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 41}$  xlabel($\color{mdarkgrey}$'Frequency (Hz)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 42}$  axis([990 $\color{mdarkgrey}$1010 0 0.5])$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 43}$  saveas(gca, $\color{mdarkgrey}$'../figs/hw6_fm_di'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 44}$  $\\
 \hspace*{-2em}{\scriptsize 45}$  $\color{mgrey}$% (ii) $\color{black}$$\\
 \hspace*{-2em}{\scriptsize 46}$  figure$\\
 \hspace*{-2em}{\scriptsize 47}$  spectrogram(x, $\color{mdarkgrey}$256, 250, 256, 8e3);$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 48}$  saveas(gca, $\color{mdarkgrey}$'../figs/hw6_fm_dii'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 49}$  $\\
 \hspace*{-2em}{\scriptsize 50}$  $\color{mgrey}#%% e)#\color{black}$$\\
 \hspace*{-2em}{\scriptsize 51}$  beta = 500;$\\
 \hspace*{-2em}{\scriptsize 52}$  N = 32768;$\\
 \hspace*{-2em}{\scriptsize 53}$  n = 0:N-1;$\\
 \hspace*{-2em}{\scriptsize 54}$  $\\
 \hspace*{-2em}{\scriptsize 55}$  x = cos(pi/4*n + beta*sin(pi*n/4e3));$\\
 \hspace*{-2em}{\scriptsize 56}$  $\color{mgrey}$% soundsc(x)$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 57}$  $\\
 \hspace*{-2em}{\scriptsize 58}$  $\color{mgrey}$% (i)$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 59}$  dt = 1/8e3;$\\
 \hspace*{-2em}{\scriptsize 60}$  df = 1/(N*dt);$\\
 \hspace*{-2em}{\scriptsize 61}$  f = -1/(2*dt):df:1/(2*dt)-df;$\\
 \hspace*{-2em}{\scriptsize 62}$  X = fftshift(fft(x, N)/N);$\\
 \hspace*{-2em}{\scriptsize 63}$  $\\
 \hspace*{-2em}{\scriptsize 64}$  figure$\\
 \hspace*{-2em}{\scriptsize 65}$  plot(f, abs(X), $\color{mdarkgrey}$'k'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 66}$  ylabel($\color{mdarkgrey}$'|X(j\Omega)|'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 67}$  xlabel($\color{mdarkgrey}$'Frequency (Hz)'$\color{black}$, $\color{mdarkgrey}$'FontSize'$\color{black}$, 12)$\\
 \hspace*{-2em}{\scriptsize 68}$  saveas(gca, $\color{mdarkgrey}$'../figs/hw6_fm_ei'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\
 \hspace*{-2em}{\scriptsize 69}$  $\\
 \hspace*{-2em}{\scriptsize 70}$  $\color{mgrey}$% (ii) $\color{black}$$\\
 \hspace*{-2em}{\scriptsize 71}$  figure$\\
 \hspace*{-2em}{\scriptsize 72}$  spectrogram(x, $\color{mdarkgrey}$256, 250, 256, 8e3);$\color{black}$$\\
 \hspace*{-2em}{\scriptsize 73}$  saveas(gca, $\color{mdarkgrey}$'../figs/hw6_fm_eii'$\color{black}$, $\color{mdarkgrey}$'epsc'$\color{black}$)$\\ 
  
\UndefineShortVerb{\$} 
\UndefineShortVerb{\#}