1 function objout = set(obj,varargin)
\r
2 % Sets the properties of an object.
\r
4 % set(obj, 'propertyname', value) sets the property 'propertyname' of the object 'obj'
\r
5 % to the value 'value'.
\r
7 % An equivalent syntax is obj.propertyname = value.
\r
9 % set(obj, 'property1', value1, 'property2', value2, ...) sets multiple property values.
\r
10 % set(obj, 'property') displays legitimate values for the specified property of 'obj'.
\r
11 % set(obj) displays all properties of 'obj' and their admissible values.
\r
13 % If an output argument is specified, the modified object will be assigned to this and
\r
14 % no modifications will be done to the input object.
\r
16 % Type 'props(obj)' for more details on the properties of the object 'obj'.
\r
18 % Toolbox for nonlinear filtering.
\r
19 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
21 % This program is free software; you can redistribute it and/or
\r
22 % modify it under the terms of the GNU General Public License
\r
23 % as published by the Free Software Foundation; either version 2
\r
24 % of the License, or (at your option) any later version.
\r
26 % This program is distributed in the hope that it will be useful,
\r
27 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
29 % GNU General Public License for more details.
\r
31 % You should have received a copy of the GNU General Public License
\r
32 % along with this program; if not, write to the Free Software
\r
33 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
36 % Only 'obj' is supplied. Display the list of properties.
\r
39 % A parameter was given, but no value. Display information about the property.
\r
40 prop_name = varargin{1};
\r
41 [props,rprops]=pnames;
\r
42 if findcstr(props,prop_name)||findcstr(rprops,prop_name)
\r
43 disp(pformat(get(obj,prop_name)));
\r
45 error('Unknown property');
\r
48 if isempty(inputname(1))&&nargout<1
\r
49 error('The first argument must be a named variable if no output argument is given.')
\r
50 elseif rem(nargin-1,2)~=0,
\r
51 error('Property/value pairs must come in even number.')
\r
54 property_argin = varargin;
\r
55 while length(property_argin) >= 2,
\r
56 prop_name = property_argin{1};
\r
57 v = property_argin{2};
\r
58 property_argin = property_argin(3:end);
\r
62 % Here we handle properties that need custom treatment (or need to be
\r
63 % processed really fast)
\r
67 obj.xpred=calc_x0(model,1);
\r
68 obj.Ppred=get(model,'P0');
\r
69 obj.model=initgradients(model);
\r
74 [props,rprops]=pnames;
\r
75 if findcstr(props,prop_name)
\r
76 eval(strcat('obj.',prop_name,'=v;'));
\r
77 elseif findcstr(rprops,prop_name)
\r
78 error([prop_name,' is a read-only property'])
\r
80 error([prop_name,' is not a valid property'])
\r
86 % No output variable was specified by the user.
\r
87 % We'll do the assignment manually in the caller's workspace.
\r
88 objname = inputname(1);
\r
89 assignin('caller',objname,obj)
\r