function [vb,vnb] = find_right_speed(subject,pltcol)

speeds = 0.75:0.25:2;

if strcmp(subject,'DH110912')==1
  costb = 2.49*65/80.285849;
  ebarb = .07*65/80.285849;
  costw = [4.13 4.90 5.77 6.91 8.29 10.73]*65/80.285849; 
  ebarw = [0.10 0.10 0.12 0.14 0.16 0.21]*65/80.285849;
elseif strcmp(subject,'DH121412')==1
  costb = [];
  ebarb = [];
  costw = [3.95 4.40 5.42 6.68 8.33 11.04]*65/80.285849; 
  ebarw = [0.07 0.09 0.11 0.13 0.14 0.20]*65/80.285849;  
elseif strcmp(subject,'MC121812')==1
  costb = [];
  ebarb = [];
  costw = [3.64 3.90 4.77 5.59 6.77 8.24]*65/72.3432; 
  ebarw = [0.09 0.10 0.11 0.12 0.15 0.21]*65/72.3432;
elseif strcmp(subject,'JB011613')==1
  costb = 1.60*65/68.8821;
  ebarb = 0.07*65/68.8821;
  costw = [3.36 3.88 4.76 5.82 7.36 9.49]*65/68.8821; 
  ebarw = [0.11 0.10 0.11 0.12 0.17 0.17]*65/68.8821;  
elseif strcmp(subject,'BC011113')==1
  costb = 1.63*65/64.9790;
  ebarb = 0.06*65/64.9790;  
  costw = [3.55 4.03 4.55 5.72 7.11 9.21]*65/64.9790; 
  ebarw = [0.09 0.13 0.13 0.20 0.16 0.21]*65/64.9790;  
elseif strcmp(subject,'DC011413')==1
  costb = 1.38*65/64.0327;
  ebarb = 0.06*65/64.0327;
  costw = [3.17 3.38 3.94 4.61 5.59 7.26]*65/64.0327; 
  ebarw = [.11 .13 .15 .14 .14 .16]*65/64.0327;  
else
  fprintf('Invalid subject ID\n');
  return;
end;

x1 = 0.75:.01:2.00;

mcot1       = costw./speeds/9.80665;
emcot1      = ebarw./speeds/9.80665;
coeff1      = polyfit(speeds,mcot1,2); 
mcot3       = polyval(coeff1,speeds);
y1          = interp1(speeds,mcot3,x1,'spline');
[val1,ind1] = min(y1); 
vb = x1(ind1);

vnb = [];
if length(costb) > 0  
  costw2     = costw - costb*ones(size(costw));
  ebarw2     = sqrt(ebarw.^2 + (ebarb*ones(size(ebarw))).^2); 
  mcot2      = costw2./speeds/9.80665;
  emcot2     = ebarw2./speeds/9.80665;
  coeff2     = polyfit(speeds,mcot2,2);
  mcot4      = polyval(coeff2,speeds);   
  y2          = interp1(speeds,mcot4,x1,'spline');
  [val2,ind2] = min(y2);
  vnb         = x1(ind2);  
end;  
  
%figure
eval(['plot(x1,y1,''' pltcol ''',''linewidth'',3);']);
hold on;
eval(['errorbar(speeds,mcot1,emcot1,''' pltcol '.'',''linewidth'',3,''markersize'',27);']);
%if length(costb) > 0
  %plot(x1,y2,'r','linewidth',3);
  %hold on;
  %errorbar(speeds,mcot2,emcot2,'r.','linewidth',3,'markersize',27);
%end;
grid on; 
xlabel('Walking Speed (m/s)','fontsize',14);
%ylabel('MCOT (J/kg/m)','fontsize',14);
ylabel('MCOT','fontsize',14);
title('Metabolic Cost of Transport vs. Speed','fontsize',14);