function [] = PlotVelocities(data)


title_str = (['Velocities Statistics for ' datestr(data.Time_DateNum(1)) ' -> ' datestr(data.Time_DateNum(end)) ]);
disp(['Computing ' title_str]);


%Compute Velocities
v0(1,:) = data.RC_NortekVel(:,3)';  %Velocities of rigid body at sample point, x (1) is to the front, y (2) is up.
v0(2,:) = data.RC_NortekVel(:,1)';
th_dot = data.RC_AngRate(:,2)';

r0 = 0.0254*[90.63 ; 4.08];
r1 = 0.0254*[78.45 ; 8.28];
rm = 0.0254*[0 ; 8.28];
r12 = 0.0254*[-75.55 ; 8.28];

r = cell(12,1);
r{1} = 0.0254*[78.45 ; 8.28];
for j = 2:12
   r{j} = r{j-1}-0.0254*[14 ; 0]; 
end

for i = 1:length(th_dot)
   v(1,i) = v0(1,i)-th_dot(i)*(-r0(2));
   v(2,i) = v0(2,i)-th_dot(i)*(r0(1));
end

%Compute Water Velocity relative to foil at front, mid, and back foils.
v_w = cell(12,1);
alpha = cell(12,1);
F = cell(12,1);
Mag_all = [];
theta_all = [];
for j = 1:length(r)    
  v_w{j} = zeros(2,length(th_dot));
  theta{j} = zeros(1,length(th_dot));
  Mag{j} = zeros(1,length(th_dot));
    for i = 1:length(th_dot)
      v_w{j}(1,i) = -(v(1,i)+th_dot(i)*(-r{j}(2)));
      v_w{j}(2,i) = -(v(2,i)+th_dot(i)*(r{j}(1)));
      theta{j}(i) = (180/pi)*atan2(-v_w{j}(2,i),-v_w{j}(1,i));
      Mag{j}(i) = (v_w{j}(2,i).^2+v_w{j}(1,i).^2).^.5;
    end
    %Re{j} = Mag{j}*C/nu;
    Mag_all = [Mag_all Mag{j}];
    theta_all = [theta_all theta{j}];
end



    figure('Position',[ 1000          44         974       1454]); K = 4; k = 1;
    ah(k)= subplot(K,1,k); k = k+1;
    plot(data.t,Mag{6})
    ylabel('Water speed (m/s)');

    ah(k)= subplot(K,1,k); k = k+1;
    plot(data.t,theta{6});
    hold all
    plot(data.t,data.FlapAngle)
    legend('Water angle (theta, deg)','Flap Angle');
    ylabel('deg');
    
    
    
    ah(k)= subplot(K,1,k); k = k+1;
  plot(data.t,data.FlapAngle'-theta{6});
    ylabel('AOA (deg)');
    
    linkaxes(ah,'x'); 
    
    ah(k)= subplot(K,1,k); k = k+1;
    plot(theta_all,Mag_all,'.')
    hold all
    plot(theta{6},Mag{6},'rx');
    
    
    %Bin Angles
    theta_bin = 10;
    theta_midpt = [-180+theta_bin/2:theta_bin:180-theta_bin/2];
    for i = 1:length(theta_midpt)
      idx{i} = find((theta_all < theta_midpt(i)+theta_bin/2) & (theta_all > theta_midpt(i)-theta_bin/2) & (Mag_all < 1));
      cnt(i) = length(idx{i}); 
      if(abs(theta_midpt(i)) < 60)
        figure
        hist(Mag_all(idx{i}),50);
        title(['Theta MidPoint = ' num2str(theta_midpt(i)) 'deg']);
        legend(['Mean = ' num2str(mean(Mag_all(idx{i})))]);
      end
    end
    
    figure
    plot(theta_midpt,cnt,'x');
    
    

    
    
end

