make_struct_jd

PURPOSE ^

SYNOPSIS ^

function varargout = make_struct_jd(loadstruct,display_mode,fun,varargin)

DESCRIPTION ^

 This function looks into "loadstruct" for the outputs of function "fun"
 If the outputs are present, they are returned
 Otherwise, they are calculated by "fun" using "varargin"

 by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and Y.Peysson (CEA-IRFM) <yves.peysson@cea.fr>

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = make_struct_jd(loadstruct,display_mode,fun,varargin)
0002 %
0003 % This function looks into "loadstruct" for the outputs of function "fun"
0004 % If the outputs are present, they are returned
0005 % Otherwise, they are calculated by "fun" using "varargin"
0006 %
0007 % by J. Decker (CEA-IRFM) <joan.decker@cea.fr> and Y.Peysson (CEA-IRFM) <yves.peysson@cea.fr>
0008 %
0009 if isfield(loadstruct,fun) && isstruct(loadstruct.(fun)),% specific function outputs are recalled
0010     if display_mode >= 1,
0011         disp(['Outputs of the function ',fun,' retrieved from the structure ',inputname(1)]);
0012     end
0013     varargout = struct2cell(loadstruct.(fun));     
0014 else % specific function outputs are calculated
0015     funhandle = str2func(fun);%make string into function handle
0016     varargout = cell(1,nargout);
0017     [varargout{:}] = funhandle(varargin{:});%evaluate function
0018 end

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.