% STRUCT2OBJ converts the input structure into the given object.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: STRUCT2OBJ converts the input structure into the given object.%% CALL: obj = struct2obj(s, class)%% INPUTS: s - the structure to convert% class - the class of the object to convert to%%% OUTPUTS: obj - the converted object%% VERSION: $Id: struct2obj.m,v 1.2 2008/07/03 18:20:25 ingo Exp $%% HISTORY: 09-05-07 M Hewitson% Creation%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%function varargout = struct2obj(varargin)% Get inputsif isstruct(varargin{1}) s = varargin{1};else error('### Incorrect usage. The first argument should be a structure.');endif ischar(varargin{2}) cl = varargin{2};else error('### Incorrect usage. The second argument should be a class name (string).');end% Make an empty objecteobj = eval(cl);% Get the specification of the required typefnames = fieldnames(eobj);% Loop over fields and try to set them from the structure% Set outputvarargout{1} = [];