function z = zfunction(varargin)
%ZFUNCTION  Limit state function

%% create samples structure
% convert input arguments (varargin) to samples structure
samples = struct(varargin{:});

%% calculate z
% in this case: z = R - S
z = samples.R - samples.S;