%
%  This file processes the data from the first trial
%
function data = process_data_3carts;
%
%  enter the data as 
%       frequency        input (in volts)    output amplitude (in cm) for X1 X2 X3; 
%
%  such as 
%
%  measured = [1.00 1.50 1740 1500 2500;
%              2.00 1.50 2300 1500 2800;
%              2.50 0.50 1100   0  1000];
%

  measured = [ 0.50 0.02 0.775 0.623 0.315;
               1.00 0.02 1.950 1.700 0.908;
               1.50 0.02 0.843 0.820 0.473;
               2.00 0.03 0.445 0.514 0.339;
               2.50 0.03 0.201 0.306 0.237;
               3.00 0.05 0.115 0.395 0.415;
               3.50 0.05 0.181 0.416 0.753;
               4.00 0.02 0.254 0.092 0.574;
               4.50 0.05 0.211 0.182 0.459;
               5.00 0.05 0.067 0.366 0.393;
               5.50 0.05 0.554 0.808 0.527;
               6.00 0.05 0.206 0.174 0.089;
               6.50 0.05 0.141 0.085 0.031;
               1.10 0.01 0.717 0.647 0.356;
               1.20 0.01 0.576 0.516 0.286;
               1.30 0.01 0.438 0.405 0.233;
               1.40 0.01 0.325 0.306 0.179;
               3.60 0.05 0.391 0.521 1.216;
               3.70 0.03 0.385 0.355 1.025;
               3.80 0.02 0.414 0.257 0.978;
               3.90 0.02 0.367 0.154 0.802;
               3.10 0.05 0.069 0.376 0.450;
               3.20 0.05 0.055 0.363 0.476;
               3.30 0.05 0.082 0.373 0.542;
               3.40 0.05 0.125 0.387 0.637];
%
% be sure the row are sorted by frequency
%
  measured = sortrows(measured,1);
%
%  get the magnitude of the transfer function
%
  H1 = measured(:,3)./measured(:,2);
  H2 = measured(:,4)./measured(:,2);
  H3 = measured(:,5)./measured(:,2);
  f = measured(:,1); 
  data = [f H1 H2 H3];
%
  return;