function check_param(required_param, given_param)

% function check_param(required_param, given_param)
%
% Check that all strings listed in the cell array "required_param"
% are present in the cell array "given_param".
% 
% If it is not the case, an error is thrown.
%
% Typical use: verify that a structure contains
% at least some required fields:
%
%   my_structure.my_param1 = 1.234;
%   my_structure.my_param2 = 'abcd';
%
%   check_param( { 'my_param1', 'my_param2' }, fieldnames( my_structure ) );
  
aux = ismember(required_param, given_param);

if ~all(aux)
  s = sprintf('Some of the required parameters are missing:');
  v = required_param( ~aux );
  for a = 1:length( v )
    s = [ s sprintf( [ '\n  ' v{ a } ] ) ];
  end
  s = [ s sprintf( '\nAborted.') ];
  error( s );
end
