1 %> @brief Dataset loader/saver
for mat files
3 %> mat files are a bit tricky because the structure has evolved since the
4 %> beginning and backward compatibility is needed, but it is very stable now.
7 %------------------------------------------------------------------
9 function data = load(o, range)
16 %> *1* checks for dataclass variable within file
17 load(o.filename, '-mat', 'dataclass');
18 if ~exist('dataclass', 'var')
22 %
irverbose(sprintf('new ''%s'' from file ''%s''...', dataclass, o.filename), 0);
23 data = eval(dataclass);
27 load(o.filename, '-mat', 'DATA');
29 irerror(['MATLAB couldn''t handle this file: ', ME.message]);
32 if ~exist('DATA', 'var')
33 irerror(sprintf('File ''%s'' does not contain a variable called ''DATA''', o.filename));
36 data = data.import_from_struct(DATA);
38 %> TODO This is a hack present until I do a proper wavenumber record
39 %> while importing Pirouette files and make MATLAB import and record
40 %> these information (and re-generate the .mat files).
42 data.fea_x = linspace(range(1), range(2), size(DATA.X, 2));
44 if isempty(data.fea_x)
45 irwarning('x vector was empty, default x wavenumber vector will be used');
46 data.fea_x = linspace(o.defaultrange(1), o.defaultrange(2), size(DATA.X, 2));
51 data.assert_not_nan();
52 data.filename = o.filename;
53 data.filetype = 'mat';
54 data = data.make_groupnumbers();
59 %------------------------------------------------------------------
61 function o = save(o, data)
62 dataclass = class(data); %
#ok<*NASGU>
65 save(o.filename,
'DATA',
'dataclass');
66 irverbose(sprintf(
'Just saved file "%s"', o.filename), 2);
function irverbose(in s, in level)
Dataset loader/saver common class.
Dataset loader/saver for mat files.