Mercurial > hg > ltpda
comparison m-toolbox/classes/@smodel/sop.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 % SOP apply a symbolic operation to the expression. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SOP apply a symbolic operation to the expression. | |
5 % objects. | |
6 % | |
7 % CALL: obj = sop(mdl, plist) | |
8 % obj = mdl.sop(plist) | |
9 % | |
10 % <a href="matlab:utils.helper.displayMethodInfo('smodel', 'sop')">Parameters Description</a> | |
11 % | |
12 % VERSION: $Id: sop.m,v 1.7 2011/04/08 08:56:28 hewitson Exp $ | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 | |
16 function sop(mdls, callerIsMethod, smodel_invars, operation, args, pl, info, varargin) | |
17 | |
18 import utils.const.* | |
19 | |
20 if isempty(operation) | |
21 error('### Please give a valid symbolic operator'); | |
22 end | |
23 | |
24 % Loop over the input objects | |
25 for jj = 1:numel(mdls) | |
26 % Message | |
27 utils.helper.msg(msg.PROC1, 'applying %s to %s ', operation, mdls(jj).name); | |
28 | |
29 % Fix syntax (replacing .* with * and so) to allow symbolic evaluation | |
30 mdls(jj).expr.s = utils.prog.convertComString(mdls(jj).expr.s , 'ToSymbolic'); | |
31 | |
32 % Go symbolic now | |
33 d = feval(operation, sym(mdls(jj).expr.s), args{:}); | |
34 | |
35 % Go back to string | |
36 mdls(jj).expr.s = utils.prog.mup2mat(d); | |
37 | |
38 % Replace * like expressions with .* to allow numeric evaluation | |
39 mdls(jj).expr.s = utils.prog.convertComString(mdls(jj).expr.s , 'FromSymbolic'); | |
40 | |
41 % In the case of transforms, sets the new x variable | |
42 switch lower(operation) | |
43 case {'laplace', 'ilaplace', 'fourier', 'ifourier', 'ztrans', 'iztrans'} | |
44 if ~isempty(args) | |
45 % The return variable is the last argument | |
46 mdls(jj).xvar = args{end}; | |
47 end | |
48 otherwise | |
49 end | |
50 | |
51 if ~callerIsMethod | |
52 % Set new AO name | |
53 mdls(jj).name = [operation '(' smodel_invars{jj} ')']; | |
54 % Add history step | |
55 mdls(jj).addHistory(info, pl, smodel_invars(jj), mdls(jj).hist); | |
56 end | |
57 end | |
58 | |
59 end | |
60 |