comparison m-toolbox/m/built_in_models/ao/ao_model_step.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 % AO_MODEL_STEP constructs a step-function time-series
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: AO_MODEL_STEP constructs a step-function time-series
5 %
6 % CALL: a = ao(plist('built-in', 'step'), pl);
7 %
8 % OUTPUTS:
9 % mdl - an AO object representing the time-series of the signal
10 %
11 %
12 % INFO:
13 % <a href="matlab:utils.models.displayModelOverview('ao_model_step')">Model Information</a>
14 %
15 %
16 % REFERENCES:
17 %
18 %
19 % VERSION: $Id: ao_model_step.m,v 1.4 2011/04/29 08:04:07 hewitson Exp $
20 %
21 % HISTORY:
22 %
23 %
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
26 function varargout = ao_model_step(varargin)
27
28 varargout = utils.models.mainFnc(varargin(:), ...
29 mfilename, ...
30 @getModelDescription, ...
31 @getModelDocumentation, ...
32 @getVersion, ...
33 @versionTable);
34
35 end
36
37 %--------------------------------------------------------------------------
38 % AUTHORS EDIT THIS PART
39 %--------------------------------------------------------------------------
40
41 function desc = getModelDescription
42 desc = 'Constructs a step-function time-series';
43 end
44
45 function doc = getModelDocumentation
46 doc = sprintf([...
47 'No documentation at the moment' ...
48 ]);
49 end
50
51 % default version is always the first one
52 function vt = versionTable()
53
54 vt = {...
55 'Initial version', @version01, ...
56 };
57
58 end
59
60
61 % This version is the initial one
62 %
63 function varargout = version01(varargin)
64
65 if nargin == 1 && ischar(varargin{1})
66 switch varargin{1}
67 case 'plist'
68
69 % The plist for this version of this model
70 pl = plist();
71
72 % parameters 'Fs', 'Nsecs', 'Xunits'
73 pl.append(plist.TSDATA_PLIST);
74
75 % parameter 'A'
76 p = param({'A','Amplitude of the signal.'}, {1, {1}, paramValue.OPTIONAL});
77 pl.append(p);
78
79 % parameter 'Toff'
80 p = param({'Toff', ['Offset of the step, as a number of seconds']}, {1, {0}, paramValue.OPTIONAL});
81 pl.append(p);
82
83 % parameter 'Yunits'
84 p = param({'yunits','Unit on Y axis.'}, paramValue.STRING_VALUE(''));
85 pl.append(p);
86
87 % set output
88 varargout{1} = pl;
89
90 case 'description'
91 varargout{1} = 'This version is the initial one';
92 case 'info'
93 varargout{1} = [];
94 otherwise
95 error('unknown inputs');
96 end
97 return;
98 end
99
100 % build model
101 pl = varargin{1};
102 fs = find(pl, 'fs');
103 nsecs = find(pl, 'nsecs');
104 A = find(pl, 'A');
105 toff = find(pl, 'toff');
106 xunits = find(pl, 'xunits');
107 yunits = find(pl, 'yunits');
108
109 % build data vectors
110 t = 0 : 1/fs : nsecs - 1/fs;
111 y = A*(t >= toff);
112
113 % Build a time-series AO and set its name, X-units, Y-units
114 spl = plist(...
115 'xvals', t, ...
116 'yvals', y, ...
117 'type', 'tsdata', ...
118 'fs', fs, ...
119 'xunits', 's', ...
120 'yunits', yunits, ...
121 'name', 'Step' ...
122 );
123
124 a = ao(spl);
125 a.setProcinfo(spl);
126
127 varargout{1} = a;
128
129 end
130
131
132 %--------------------------------------------------------------------------
133 % AUTHORS SHOULD NOT NEED TO EDIT BELOW HERE
134 %--------------------------------------------------------------------------
135
136
137 %--------------------------------------------------------------------------
138 % Get Version
139 %--------------------------------------------------------------------------
140 function v = getVersion
141
142 v = '$Id: ao_model_step.m,v 1.4 2011/04/29 08:04:07 hewitson Exp $';
143
144 end
145