Mercurial > hg > ltpda
comparison m-toolbox/classes/@tsdata/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 = update_struct(obj_struct, version_str); | |
10 % | |
11 % VERSION: $Id: update_struct.m,v 1.10 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 if isempty(obj_struct.fs) | |
34 obj_struct.fs = NaN; | |
35 end | |
36 | |
37 catch ME | |
38 disp(varargin{1}); | |
39 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (fsdata) above is not from version 1.0'))); | |
40 end | |
41 | |
42 struct_ver = '1.9.1'; | |
43 end | |
44 | |
45 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%% | |
46 | |
47 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
48 strcmp(struct_ver, '1.9.1') | |
49 | |
50 %%% update xunits | |
51 if ~isa(obj_struct.xunits, 'unit') | |
52 % Make sure we have strings for the units | |
53 obj_struct.xunits = char(obj_struct.xunits); | |
54 | |
55 % Set default value ('empty') in 1.9.1 to an empty string to avoid warnings. | |
56 if strcmp(obj_struct.xunits, 'empty') | |
57 obj_struct.xunits = ''; | |
58 end | |
59 | |
60 % We need to fix any strange old units | |
61 obj_struct.xunits = strrep(obj_struct.xunits, 'N/A', 'arb'); | |
62 obj_struct.xunits = strrep(obj_struct.xunits, 'Arb', 'arb'); | |
63 | |
64 % Check X units | |
65 try | |
66 uo = unit(obj_struct.xunits); | |
67 catch | |
68 warning('!!! This file contains a fsdata object with unsupported x-units [%s]. Setting to empty.', obj_struct.xunits); | |
69 obj_struct.xunits = ''; | |
70 end | |
71 end | |
72 | |
73 %%% update yunits | |
74 if ~isa(obj_struct.yunits, 'unit') | |
75 % Make sure we have strings for the units | |
76 obj_struct.yunits = char(obj_struct.yunits); | |
77 | |
78 % Set default value ('empty') in 1.9.1 to an empty string to avoid warnings. | |
79 if strcmp(obj_struct.yunits, 'empty') | |
80 obj_struct.yunits = ''; | |
81 end | |
82 | |
83 % We need to fix any strange old units | |
84 obj_struct.yunits = strrep(obj_struct.yunits, 'N/A', 'arb'); | |
85 obj_struct.yunits = strrep(obj_struct.yunits, 'Arb', 'arb'); | |
86 | |
87 % Check Y units | |
88 try | |
89 uo = unit(obj_struct.yunits); | |
90 catch | |
91 warning('!!! This file contains a fsdata object with unsupported y-units [%s]. Setting to empty.', obj_struct.yunits); | |
92 obj_struct.yunits = ''; | |
93 end | |
94 end | |
95 | |
96 struct_ver = '1.9.2'; | |
97 end | |
98 | |
99 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%% | |
100 | |
101 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
102 strcmp(struct_ver, '1.9.2') | |
103 | |
104 struct_ver = '1.9.3'; | |
105 end | |
106 | |
107 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%% | |
108 | |
109 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
110 strcmp(struct_ver, '1.9.3') | |
111 | |
112 struct_ver = '1.9.4'; | |
113 end | |
114 | |
115 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%% | |
116 | |
117 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
118 strcmp(struct_ver, '1.9.4') | |
119 | |
120 struct_ver = '2.0'; | |
121 end | |
122 | |
123 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%% | |
124 | |
125 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
126 strcmp(struct_ver, '2.0') | |
127 | |
128 struct_ver = '2.0.1'; | |
129 end | |
130 | |
131 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%% | |
132 | |
133 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
134 strcmp(struct_ver, '2.0.1') | |
135 | |
136 struct_ver = '2.1'; | |
137 end | |
138 | |
139 varargout{1} = obj_struct; | |
140 end | |
141 |