Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/mrdivide.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 % MRDIVIDE implements mrdivide operator for smodel objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: MRDIVIDE implements mrdivide operator for smodel objects. | |
5 % | |
6 % CALL: obj = obj1/obj2 | |
7 % obj = rdivide(obj1,obj2); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'mrdivide')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: mrdivide.m,v 1.8 2011/05/11 05:23:15 mauro Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function mdl = mrdivide(varargin) | |
16 | |
17 callerIsMethod = utils.helper.callerIsMethod; | |
18 | |
19 % Check if this is a call for parameters | |
20 if utils.helper.isinfocall(varargin{:}) | |
21 mdl = getInfo(varargin{3}); | |
22 return | |
23 end | |
24 | |
25 if nargout == 0 | |
26 error('### Matrix division operator can not be used as a modifier.'); | |
27 end | |
28 | |
29 mdl1 = varargin{1}; | |
30 mdl2 = varargin{2}; | |
31 | |
32 % Convert numbers into a smodel object | |
33 if isnumeric(mdl1) | |
34 mdl1 = smodel(mdl1); | |
35 end | |
36 if isnumeric(mdl2) | |
37 mdl2 = smodel(mdl2); | |
38 end | |
39 | |
40 %----------------- Gather the input objects names and history | |
41 in_names = cell(size(varargin)); | |
42 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
43 | |
44 % Convert cdata aos into a smodel object | |
45 if isa(mdl2, 'ao') | |
46 if isa(mdl2.data, 'cdata') && numel(mdl2.data.y) == 1 | |
47 mdl2 = smodel(mdl2.y); | |
48 else | |
49 error('### It is not possible to divide the two objects!'); | |
50 end | |
51 end | |
52 | |
53 mdl = copy(mdl1, true); | |
54 mdl.expr = msym(['(' mdl.expr.s ')/(' mdl2.expr.s ')']); | |
55 mdl.name = ['(' mdl.name ')*(' mdl2.name ')']; | |
56 | |
57 smodel.mergeFields(mdl1, mdl2, mdl, 'params', 'values'); | |
58 smodel.mergeFields(mdl1, mdl2, mdl, 'aliasNames', 'aliasValues'); | |
59 smodel.mergeFields(mdl1, mdl2, mdl, 'xvar', 'xvals'); | |
60 smodel.mergeFields(mdl1, mdl2, mdl, 'xvar', 'xunits'); | |
61 smodel.mergeFields(mdl1, mdl2, mdl, 'xvar', 'trans'); | |
62 | |
63 if ~callerIsMethod | |
64 mdl.addHistory(getInfo('None'), [], in_names, [mdl1.hist mdl2.hist]); | |
65 end | |
66 | |
67 end | |
68 | |
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
70 % Local Functions % | |
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
72 | |
73 %-------------------------------------------------------------------------- | |
74 % Get Info Object | |
75 %-------------------------------------------------------------------------- | |
76 function ii = getInfo(varargin) | |
77 | |
78 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
79 sets = {}; | |
80 pl = []; | |
81 else | |
82 sets = {'Default'}; | |
83 pl = getDefaultPlist(); | |
84 end | |
85 % Build info object | |
86 ii = minfo(mfilename, 'smodel', 'ltpda', utils.const.categories.aop, '$Id: mrdivide.m,v 1.8 2011/05/11 05:23:15 mauro Exp $', sets, pl); | |
87 ii.setArgsmin(2); | |
88 ii.setModifier(false); | |
89 end | |
90 | |
91 %-------------------------------------------------------------------------- | |
92 % Get Default Plist | |
93 %-------------------------------------------------------------------------- | |
94 function plout = getDefaultPlist() | |
95 persistent pl; | |
96 if ~exist('pl', 'var') || isempty(pl) | |
97 pl = buildplist(); | |
98 end | |
99 plout = pl; | |
100 end | |
101 | |
102 function pl = buildplist() | |
103 pl = plist.EMPTY_PLIST; | |
104 end |