function simulate_system (sys,x0,K,N,u,Tf)
%helper function for CL-system problem

t = linspace(0,Tf,300);  
u = repmat(u,300,1);

Bcl = sys.B;
if ((K ~= [0 0]))
  Ccl = [0 0;
         -K;
         1 0;
         0 1];
  Dcl = [1/N;1;0;0];
  sys = ss(sys.A,Bcl,Ccl,Dcl,'outputname',{'w','u','x1','x2'});
else
  Ccl = [0 0
         1 0;
         0 1];
  Dcl = [1/N;0;0];
  sys = ss(sys.A,Bcl,Ccl,Dcl,'outputname',{'u','x1','x2'});
end



lsim(sys,u,t,x0);