% s_ventil.m

function [sys,x0,str,ts] = s_co2ventil(t,x,u,flag)
% u = [p rho H]_tank, z, [p T]_1.kontrollvolumPC
global b
switch flag


  % INITALIZATION
  % -------------
  case 0,
    [sys,x0,str,ts]=Initialize;

  
  % OUTPUTS 
  % -------
  case 3,
    sys = co2ventil(u);

  case { 1, 2, 4, 9 }
    sys=[];

  % UNEXPECTED FLAGS
  % ----------------
  otherwise
    error(['Unhandled flag = ',num2str(flag)]);

end

% end sfuntmpl

%
%=============================================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-function.
%=============================================================================
%

function [sys,x0,str,ts]=Initialize
global b
%
% call simsizes for a sizes structure, fill it in and convert it to a
% sizes array.
%
% Note that in this example, the values are hard coded.  This is not a
% recommended practice as the characteristics of the block are typically
% defined by the S-function parameters.
%
sizes = simsizes;

sizes.NumContStates  = 0;
sizes.NumDiscStates  = 0;
sizes.NumOutputs     = 5; % wl wv Htot
sizes.NumInputs      = 6; % rho,H,pinn, z, p og T etter ventil
sizes.DirFeedthrough = 1; % 0 hvis utgang ikke direkte funksjon av inngang, ellers 1
sizes.NumSampleTimes = 1; % at least one sample time is needed

sys = simsizes(sizes);

% initialize the initial conditions
x0 = []; % temp
%
% str is always an empty matrix
str = [];

% initialize the array of sample times
ts  = [0 0];
%data=initialize;
% end mdlInitializeSizes

