function gc = controller(type, kc, ti)

% --------------------------------------------------------------------- %
%                  --    Controller Funciton     --                     %
% a funtion that selects and creates the desired controller transfer    %
% function                                                              %
% type = 1 gives a PI controller                                        %
% type = 0 gives a P controller                                         %
%                                  writen by Chriss Grimholt - 1/10-10  %
% --------------------------------------------------------------------- %


s = tf('s');

if type == 1
    gc = kc*(1+1/ti/s);   % PI Controller
elseif type == 0
    gc = tf(kc);           % P controller
else
    disp('Error: No controller type is choosen')
    return
end

end
