title: How do I calculate the transfer function of a filter in MATLAB?
body: <p>I have to do some exercises in a Digital Signal Processing course and I have some problems.</p>
  
  <p>I have a given file (signal.wav name the signal <code>x(n)</code> ) with some noise added and iIam asked to find some information from it. The noise added is <code>η(n) = sin8000πn</code>. So the signal I am processing is <code>s(n) = x(n) + η(n)</code></p>
  
  <p>In order to remove the noise, I apply a low-pass butterworth filter with <code>order = 2</code> and cutoff frequency = 2000hz.</p>
  
  <p>I want to find the transfer function <code>H(s)</code> from the filter and the <code>H(z)</code> function. Well I know that I have to apply bilinear transformation but iIdont know how to do it with MATLAB.</p>
  
  <p>Can anyone help me solve this?</p>
  
  <p>Here is my code</p>
  
  <pre><code>[y, fs, nbits] = wavread('signal.wav');
  
  % Playing the file
  disp('-&gt; Playing at the original sample rate...');
  sound(y, fs);
  
  fprintf('------------------------------------------\n');
  % Sampling frequency
  fprintf('-&gt; Sample frequency is:      %f.\n', fs);
  
  % Print the min and max values of the audio data.
  fprintf('-&gt; The maximum data value is %f.\n', max(y));
  fprintf('-&gt; The minimum data value is %f.\n', min(y));
  fprintf('------------------------------------------\n');
  
  order = 2;
  sampling_freq = fs;
  cut_off_freq = 2000;
  
  [butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq/2));
  %[butter_a, butter_b] = butter(order,cut_off_freq/(sampling_freq));
  
  subplot(211), plot(y);
  subplot(212), plot(filter(butter_a,butter_b,y));
  
  sound(filter(butter_a,butter_b,y),fs);
  </code></pre>