function Fy = Fycomb(x,varargin)

%Fycomb
%  Fy = Fycomb(slip,Bi,Ci,Di,Ei,Bo,Co,Do,Eo)
%  - or - 
%  Fy = Fycomb(slip,Bi,Ci,Di,Ei,Shi,Svi,Bo,Co,Do,Eo,Sho,Svo)
%
%  Calculate combined side force given inside and outside tire
%  parameters B, C, D and E (and possibly Sh and Sv) using a 
%  call to Fy_Pacejka.
%
%  This is an internal function called by alphaPacejka
%

% Version 1.2
% Chris Gerdes 
% Dynamic Design Lab
% Stanford University
% 4/6/2002
% Function for use with ME106/227
% This revised version also includes camber angle change.

Bi = varargin{1};
Ci = varargin{2};
Di = varargin{3};
Ei = varargin{4};

if (nargin == 9)
   Bo = varargin{5};
   Co = varargin{6};
   Do = varargin{7};
   Eo = varargin{8};
elseif (nargin == 13)
   Shi = varargin{5};
   Svi = varargin{6};
   Bo = varargin{7};
   Co = varargin{8};
   Do = varargin{9};
   Eo = varargin{10};
   Sho = varargin{11};
   Svo = varargin{12};
else
   error('Incorrect number of parameters sent to Fycomb');
end

if (nargin == 9) 
   Fyi = Fy_Pacejka(x,Bi,Ci,Di,Ei);
   Fyo = Fy_Pacejka(x,Bo,Co,Do,Eo);
   Fy = Fyi+Fyo;
else
   Fyi = Fy_Pacejka(x,Bi,Ci,Di,Ei,Shi,Svi);
   Fyo = Fy_Pacejka(x,Bo,Co,Do,Eo,Sho,Svo);
   Fy = Fyi+Fyo;
end