comparison m-toolbox/classes/@pzmodel/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 12:45:45 hewitson 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 %%% creator
34 if isfield(obj_struct, 'provenance') && ~isfield(obj_struct, 'creator')
35 obj_struct.creator = obj_struct.provenance;
36 elseif ~isfield(obj_struct, 'creator')
37 obj_struct.creator = provenance('Updater 1.0 -> 1.9.1');
38 end
39
40 %%%%% hist
41 if ~isfield(obj_struct, 'hist')
42 if isfield(obj_struct, 'class')
43 cn = obj_struct.class;
44 else
45 cn = 'unknown class. updater';
46 end
47 ii = minfo('update_struct', cn, 'ltpda', '', ...
48 '$Id: update_struct.m,v 1.10 2011/03/28 12:45:45 hewitson Exp $', ...
49 {'Default'}, plist(), 0, 0);
50 obj_struct.hist = history(time().utc_epoch_milli, ii, obj_struct.plist);
51 end
52
53 %%% poles
54 if isstruct(obj_struct.poles)
55 for ii = 1:numel(obj_struct.poles)
56 obj_struct.poles(ii).class = 'pz';
57 obj_struct.poles(ii).tbxver = '1.0';
58 end
59 obj_struct.poles = pz(obj_struct.poles);
60 end
61
62 %%% zeros
63 if isstruct(obj_struct.zeros)
64 for ii = 1:numel(obj_struct.zeros)
65 obj_struct.zeros(ii).class = 'pz';
66 obj_struct.zeros(ii).tbxver = '1.0';
67 end
68 obj_struct.zeros = pz(obj_struct.zeros);
69 end
70
71 catch ME
72 disp(varargin{1});
73 throw(addCause(ME, MException('MATLAB:LTPDA','### The struct (pzmodel) above is not from version 1.0')));
74 end
75
76 struct_ver = '1.9.1';
77 end
78
79 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%%
80
81 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
82 strcmp(struct_ver, '1.9.1')
83
84 struct_ver = '1.9.2';
85 end
86
87 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%%
88
89 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
90 strcmp(struct_ver, '1.9.2')
91
92 struct_ver = '1.9.3';
93 end
94
95 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%%
96
97 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
98 strcmp(struct_ver, '1.9.3')
99
100 %%% created
101 if isfield(obj_struct, 'created')
102 obj_struct = rmfield(obj_struct, 'created');
103 end
104
105 %%% creator
106 if isfield(obj_struct, 'creator')
107 obj_struct = rmfield(obj_struct, 'creator');
108 end
109
110 struct_ver = '1.9.4';
111 end
112
113 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%%
114
115 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
116 strcmp(struct_ver, '1.9.4')
117
118 struct_ver = '2.0';
119 end
120
121 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%%
122
123 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
124 strcmp(struct_ver, '2.0')
125
126 struct_ver = '2.0.1';
127 end
128
129 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%%
130
131 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ...
132 strcmp(struct_ver, '2.0.1')
133
134 struct_ver = '2.1';
135 end
136
137 varargout{1} = obj_struct;
138 end
139