comparison m-toolbox/classes/@cdata/update_struct.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % UPDATE_STRUCT update the input structure to the current ltpda version
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: update_struct
5 %
6 % DESCRIPTION: UPDATE_STRUCT update the input structure to the current
7 % ltpda version
8 %
9 % CALL: [obj_struct, obj_class] = update_struct(obj_struct, version_str);
10 %
11 % VERSION: $Id: update_struct.m,v 1.9 2011/03/28 18:04:44 ingo Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = update_struct(varargin)
16
17 obj_struct = varargin{1};
18 struct_ver = varargin{2};
19
20 % get the version of the current toolbox
21 tbx_ver = strtok(getappdata(0, 'ltpda_version'));
22
23 % get only the version string without the MATLAB version
24 struct_ver = strtok(struct_ver);
25
26 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.0 -> 1.9.1' %%%%%%%%%%%%%%%%%%%%%%%
27
28 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
29 strcmp(struct_ver, '1.0')
30
31 try
32
33 % obj_struct = rmfield(obj_struct, 'name');
34
35 catch ME
36 disp(varargin{1});
37 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (cdata) above is not from version 1.0')));
38 end
39
40 struct_ver = '1.9.1';
41 end
42
43 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%%
44
45 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
46 strcmp(struct_ver, '1.9.1')
47
48 if ~isa(obj_struct.yunits, 'unit')
49
50 % Make sure we have strings for the units
51 obj_struct.yunits = char(obj_struct.yunits);
52 % Set default value ('empty') in 1.9.1 to an empty string to avoid warnings.
53 if strcmp(obj_struct.yunits, 'empty')
54 obj_struct.yunits = '';
55 end
56
57 obj_struct.yunits = strrep(obj_struct.yunits, 'N/A', ' arb');
58
59 % Check Y units
60 try
61 uo = unit(obj_struct.yunits);
62 catch
63 warning('!!! This file contains a fsdata object with unsupported y-units [%s]. Setting to empty.', obj_struct.yunits);
64 obj_struct.yunits = '';
65 end
66 end
67
68 struct_ver = '1.9.2';
69 end
70
71 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%%
72
73 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
74 strcmp(struct_ver, '1.9.2')
75
76 struct_ver = '1.9.3';
77 end
78
79 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%%
80
81 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
82 strcmp(struct_ver, '1.9.3')
83
84 struct_ver = '1.9.4';
85 end
86
87 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%%
88
89 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
90 strcmp(struct_ver, '1.9.4')
91
92 struct_ver = '2.0';
93 end
94
95 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%%
96
97 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
98 strcmp(struct_ver, '2.0')
99
100 struct_ver = '2.0.1';
101 end
102
103 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%%
104
105 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
106 strcmp(struct_ver, '2.0.1')
107
108 struct_ver = '2.1';
109 end
110
111 varargout{1} = obj_struct;
112 end
113