iload_struct_jd

PURPOSE ^

SYNOPSIS ^

function [s,spath,sfile] = iload_struct_jd(sname,sbase,sdefault,opt_gui,opt_multi,opt_id,opt_ask)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [s,spath,sfile] = iload_struct_jd(sname,sbase,sdefault,opt_gui,opt_multi,opt_id,opt_ask)
0002 %
0003 if nargin < 7,
0004     opt_ask = 0;
0005 end
0006 if nargin < 6,
0007     opt_id = 1;
0008 end
0009 if nargin < 5,
0010     opt_multi = 0;
0011 end
0012 if nargin < 4,
0013     opt_gui = 1;
0014 end
0015 if nargin < 3,
0016     sdefault = pwd;
0017 end
0018 if nargin < 2,
0019     sbase = '';
0020 end
0021 if nargin < 1,
0022     error('No structure name specified');
0023 end
0024 %
0025 s = [];
0026 sfile = [];
0027 spath = [];
0028 %
0029 if isempty(sbase),
0030     filestr = '*.mat';
0031 else
0032     filestr = [sbase,'_*.mat'];
0033 end
0034 %
0035 if opt_ask == 1,
0036     l_opt = input_dke_yp(['Do you want to load an existing structure ''',sname,''' (y/n)'],'n',{'y','n'});
0037 else
0038     l_opt = 'y';
0039 end
0040 %
0041 if strcmp(l_opt,'y'),
0042     %
0043     [filename,pathname] = igetfile_jd(opt_gui,filestr,['Please select the ',sbase,' file(s)'],sdefault,opt_multi);
0044     %
0045     if ~iscell(filename) && all(filename == 0),
0046         disp('-----> No structure specified.')
0047     else
0048         %
0049         if opt_multi == 0,
0050             %
0051             load([pathname,filename],sname);
0052             eval(['s = ',sname,';']);
0053             disp(['-----> The structure ''',sname,''' is loaded from file ',pathname,filename])
0054             s = checkid(s,opt_id);
0055             %
0056             sfile = filename;
0057             spath = pathname;
0058             %
0059         else
0060             %
0061             while iscell(filename) || all(filename ~= 0),
0062                 %
0063                 if iscell(filename) == 0,
0064                     %
0065                     load([pathname,filename],sname);
0066                     eval(['s = [s,{',sname,'}];']);
0067                     disp(['-----> The structure ''',sname,''' is loaded from file ',pathname,filename])
0068                     s{end} = checkid(s{end},opt_id);
0069                     sfile = [sfile,{filename}];
0070                     spath = [spath,{pathname}];
0071                     %
0072                 else
0073                     %
0074                     for ic = 1:length(filename),
0075                         %
0076                         load([pathname,filename{ic}],sname);
0077                         eval(['s = [s,{',sname,'}];']);
0078                         disp(['-----> The structure ''',sname,''' is loaded from file ',pathname,filename{ic}])
0079                         s{end} = checkid(s{end},opt_id);
0080                         sfile = [sfile,{filename{ic}}];
0081                         spath = [spath,{pathname}];
0082                         %
0083                     end
0084                 end
0085                 %
0086                 disp(' ');
0087                 l_opt = input_dke_yp(['Do you want to load additional structures ''',sname,''' (y/n)'],'n',{'y','n'});
0088                 %
0089                 if l_opt == 'y'
0090                     %
0091                     [filename,pathname] = igetfile_jd(opt_gui,filestr,['Please select additional ',sbase,' files (cancel if finished)'],sdefault,opt_multi);
0092                     %
0093                 else
0094                     filename = 0;
0095                 end
0096             end
0097         end
0098     end  
0099 end
0100 %
0101 function s = checkid(s,opt_id)
0102 %
0103 if opt_id && ~isfield(s,'id'),
0104     s.id = input_dke_yp(['Please provide an id for this structure'],'','');
0105 end
0106 %
0107 
0108 
0109 
0110

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