Mercurial > hg > ltpda
comparison m-toolbox/classes/@pest/fromStruct.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 % FROMSTRUCT creates from a structure a PEST object. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % FUNCTION: fromStruct | |
5 % | |
6 % DESCRIPTION: Creates from a structure a PEST object. | |
7 % | |
8 % CALL: obj = fromStruct(obj, struct) | |
9 % | |
10 % VERSION: $Id: fromStruct.m,v 1.4 2011/03/28 17:02:28 ingo Exp $ | |
11 % | |
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
13 | |
14 function objs = fromStruct(objs, obj_struct) | |
15 | |
16 % Get the class name of the object. | |
17 cn = class(objs); | |
18 | |
19 % Define function name for updating the structure | |
20 fcnName = ([cn '.update_struct']); | |
21 | |
22 % Initialize output objects | |
23 objs = feval([cn '.initObjectWithSize'], size(obj_struct, 1), size(obj_struct, 2)); | |
24 | |
25 % Update structure (if necessary) | |
26 for kk = 1:numel(obj_struct) | |
27 | |
28 % Get structure version | |
29 if isfield(obj_struct, 'tbxver') | |
30 tbxVer = obj_struct(kk).tbxver; | |
31 else | |
32 tbxVer = '1.0'; | |
33 end | |
34 % Update structure | |
35 up_struct = feval(fcnName, obj_struct(kk), tbxVer); | |
36 | |
37 % Call super-class | |
38 objs(kk) = fromStruct@ltpda_uoh(objs(kk), up_struct); | |
39 | |
40 % Set 'dy' | |
41 if isfield(up_struct, 'dy') | |
42 objs(kk).dy = up_struct.dy; | |
43 end | |
44 | |
45 % Set 'y' | |
46 if isfield(up_struct, 'y') | |
47 objs(kk).y = up_struct.y; | |
48 end | |
49 | |
50 % Set 'names' | |
51 if isfield(up_struct, 'names') | |
52 objs(kk).names = up_struct.names; | |
53 end | |
54 | |
55 % Set 'yunits' | |
56 if isfield(up_struct, 'yunits') | |
57 objs(kk).yunits = utils.helper.getObjectFromStruct(up_struct.yunits); | |
58 end | |
59 | |
60 % Set 'pdf' | |
61 if isfield(up_struct, 'pdf') | |
62 objs(kk).pdf = up_struct.pdf; | |
63 end | |
64 | |
65 % Set 'cov' | |
66 if isfield(up_struct, 'cov') | |
67 objs(kk).cov = up_struct.cov; | |
68 end | |
69 | |
70 % Set 'corr' | |
71 if isfield(up_struct, 'corr') | |
72 objs(kk).corr = up_struct.corr; | |
73 end | |
74 | |
75 % Set 'chi2' | |
76 if isfield(up_struct, 'chi2') | |
77 objs(kk).chi2 = up_struct.chi2; | |
78 end | |
79 | |
80 % Set 'dof' | |
81 if isfield(up_struct, 'dof') | |
82 objs(kk).dof = up_struct.dof; | |
83 end | |
84 | |
85 % Set 'chain' | |
86 if isfield(up_struct, 'chain') | |
87 objs(kk).chain = up_struct.chain; | |
88 end | |
89 | |
90 % Set 'models' | |
91 if isfield(up_struct, 'models') | |
92 objs(kk).models = utils.helper.getObjectFromStruct(up_struct.models); | |
93 end | |
94 | |
95 end | |
96 | |
97 end | |
98 |