function [sys,x0,str,ts] = s3(t,x,u,flag)
switch flag,
case 0
   [sys,x0,str,ts] = mdlInitializeSizes; % Initialization
case 1
   sys = mdlDerivatives(t,x,u); % Calculate derivatives
case 3
   sys = mdlOutputs(t,x,u); % Calculate outputs
case {2, 4, 9} % Unused flags
   sys = [];
otherwise
   error(['unhandled flag = ',num2str(flag)]); % Error handling
end


function [sys,x0,str,ts] = mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates  = 3;
sizes.NumDiscStates  = 0;
sizes.NumOutputs     = 1;
sizes.NumInputs      = 1;
sizes.DirFeedthrough = 0; % Matrix D is empty.
sizes.NumSampleTimes = 1;
sys = simsizes(sizes); 
x0 = [0 0 0];
str = []; 
ts = [0];   

function sys = mdlDerivatives(t,x,u)
sys(1) = -3*x(1) -3*x(2)-1*x(3)+5*u(1);
sys(2) = x(1);
sys(3) = x(2);

function sys = mdlOutputs(t,x,u)
sys=x(3);
