Mercurial > hg > ltpda
comparison m-toolbox/classes/@parfrac/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.5 2009/08/31 17:16:30 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 struct_ver = '1.9.1'; | |
32 end | |
33 | |
34 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.1' ->'1.9.2' %%%%%%%%%%%%%%%%%%%%%%% | |
35 | |
36 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
37 strcmp(struct_ver, '1.9.1') | |
38 | |
39 struct_ver = '1.9.2'; | |
40 end | |
41 | |
42 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.2' ->'1.9.3' %%%%%%%%%%%%%%%%%%%%%%% | |
43 | |
44 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
45 strcmp(struct_ver, '1.9.2') | |
46 | |
47 struct_ver = '1.9.3'; | |
48 end | |
49 | |
50 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.3' ->'1.9.4' %%%%%%%%%%%%%%%%%%%%%%% | |
51 | |
52 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
53 strcmp(struct_ver, '1.9.3') | |
54 | |
55 %%% created | |
56 if isfield(obj_struct, 'created') | |
57 obj_struct = rmfield(obj_struct, 'created'); | |
58 end | |
59 | |
60 %%% creator | |
61 if isfield(obj_struct, 'creator') | |
62 obj_struct = rmfield(obj_struct, 'creator'); | |
63 end | |
64 | |
65 struct_ver = '1.9.4'; | |
66 end | |
67 | |
68 %%%%%%%%%%%%%%%%%%%%%%% Update version '1.9.4' ->'2.0' %%%%%%%%%%%%%%%%%%%%%%% | |
69 | |
70 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
71 strcmp(struct_ver, '1.9.4') | |
72 | |
73 % It might be possible that the poles is a pz-object or a struct | |
74 for ss = 1:numel(obj_struct) | |
75 | |
76 if isa(obj_struct(ss).poles, 'pz') || isstruct(obj_struct(ss).poles) | |
77 ps = []; | |
78 for ii = 1:numel(obj_struct(ss).poles) | |
79 if ~isnan(obj_struct(ss).poles(ii).ri(1)) | |
80 if numel(obj_struct(ss).poles(ii).ri) == 2 | |
81 ps = [ps obj_struct(ss).poles(ii).ri(1) obj_struct(ss).poles(ii).ri(2)]; | |
82 else | |
83 ps = [ps obj_struct(ss).poles(ii).ri(1)]; | |
84 end | |
85 end | |
86 end | |
87 obj_struct(ss).poles = ps; | |
88 end | |
89 | |
90 % if the property 'pmul' doesn't exist then add this fieldname and | |
91 % compute the values | |
92 if ~isfield(obj_struct, 'pmul') | |
93 obj_struct(ss).pmul = mpoles( obj_struct(ss).poles, 1e-15, 0 ).'; | |
94 end | |
95 | |
96 end | |
97 | |
98 struct_ver = '2.0'; | |
99 end | |
100 | |
101 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0' ->'2.0.1' %%%%%%%%%%%%%%%%%%%%%%% | |
102 | |
103 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
104 strcmp(struct_ver, '2.0') | |
105 | |
106 struct_ver = '2.0.1'; | |
107 end | |
108 | |
109 %%%%%%%%%%%%%%%%%%%%%%% Update version '2.0.1' ->'2.1' %%%%%%%%%%%%%%%%%%%%%%% | |
110 | |
111 if utils.helper.ver2num(struct_ver) < utils.helper.ver2num(tbx_ver) && ... | |
112 strcmp(struct_ver, '2.0.1') | |
113 | |
114 struct_ver = '2.1'; | |
115 end | |
116 | |
117 varargout{1} = obj_struct; | |
118 end | |
119 |