%
% EE552 Fuzzy Controller Simulation
%
%
% Try to keep 2 velocities to be the same, this is done by controlling
% the difference to be 0
%

function [ fuzzy ] = fuzzification( data, rules )

  % Define linguistics
  plarge  = 1;
  pmedium = 2;
  psmall  = 3;
  zero    = 4;
  nsmall  = 5;
  nmedium = 6;
  nlarge  = 7;

  if data >= rules( plarge )

    fuzzy = plarge;

  elseif data >= rules( pmedium ) 

    fuzzy = pmedium;

  elseif data > rules( zero )

    fuzzy = psmall;

  elseif data == rules( zero )

    fuzzy = zero;

  elseif data <= rules( nlarge )

    fuzzy = nlarge;

  elseif data <= rules( nmedium )

    fuzzy = nmedium;

  elseif data <= rules( nsmall )

    fuzzy = nsmall;

  elseif data < rules( zero )

    fuzzy = nsmall;

  end;
