%
%  This file processes the data from the first order system
%
function data = process_data;
%
%  enter the data as 
%  f (in Hz) Vin (in mV) Vout (in mV) Vin peak time (in ms) Vout peak time (in ms); 
%
  measured = [1 1000 1000 0  0;
              20 1000 1000 0 0;
              50 1000 958 4.020 5.060;
              100 1000 846 2.040 2.960;
              200 1000 626 1.000 1.730;
              250 1000 536 0.840 1.470;
              300 1000 476 0.685  1.260;
              400 1000 378 0.500 0.980;
              500 1000 310 0.390 0.810;
              700 1000 228 0.290 0.600;
              1000 1000 164 0.190 0.435;
              1200 1000 134 0.165 0.360;
              2000 1000 86 1.102 1.226
              ];
%
%  Be sure the rows are sorted by frequency
%
   measured = sortrows(measured,1);
%
%  get the frequency of the measurement
%
  f = measured(:,1); 
%
%  get the magnitude of the transfer function
%
  mag_H = measured(:,3)./measured(:,2);
%
%  compute the time delay of the transfer function
%
  td = measured(:,5)-measured(:,4);
%
%  compute the phase of the transfer function and convert to degrees
%
  phase_H = -td.*f*360/1000;
%
%  put the data into the data array
%
  data = [f mag_H phase_H];
%
  return;