Mercurial > hg > ltpda
comparison m-toolbox/html_help/help/ug/ao_create.html @ 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 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> | |
3 | |
4 <html lang="en"> | |
5 <head> | |
6 <meta name="generator" content= | |
7 "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org"> | |
8 <meta http-equiv="Content-Type" content= | |
9 "text/html; charset=us-ascii"> | |
10 | |
11 <title>Creating Analysis Objects (LTPDA Toolbox)</title> | |
12 <link rel="stylesheet" href="docstyle.css" type="text/css"> | |
13 <meta name="generator" content="DocBook XSL Stylesheets V1.52.2"> | |
14 <meta name="description" content= | |
15 "Presents an overview of the features, system requirements, and starting the toolbox."> | |
16 </head> | |
17 | |
18 <body> | |
19 <a name="top_of_page" id="top_of_page"></a> | |
20 | |
21 <p style="font-size:1px;"> </p> | |
22 | |
23 <table class="nav" summary="Navigation aid" border="0" width= | |
24 "100%" cellpadding="0" cellspacing="0"> | |
25 <tr> | |
26 <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td> | |
27 | |
28 <td valign="baseline" align="right"><a href= | |
29 "ao_intro.html"><img src="b_prev.gif" border="0" align= | |
30 "bottom" alt="Analysis Objects"></a> <a href= | |
31 "ao_save.html"><img src="b_next.gif" border="0" align= | |
32 "bottom" alt="Saving Analysis Objects"></a></td> | |
33 </tr> | |
34 </table> | |
35 | |
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Creating Analysis Objects</h1> | |
37 <hr> | |
38 | |
39 <p> | |
40 <p>Analysis objects can be created in MATLAB in many ways. Apart from being created by the many | |
41 algorithms in the LTPDA Toolbox, AOs can also be created from initial data or descriptions | |
42 of data. The various <i>constructors</i> | |
43 are listed in the function help: <a href="matlab:doc('ao')">ao help</a>.</p> | |
44 | |
45 <h3>Examples of creating AOs</h3> | |
46 | |
47 <p>The following examples show some ways to create Analysis Objects.</p> | |
48 | |
49 <ul> | |
50 <li><a href="ao_create.html#text">Creating AOs from text files</a></li> | |
51 <li><a href="ao_create.html#xml">Creating AOs from XML or MAT files</a></li> | |
52 <li><a href="ao_create.html#fcn">Creating AOs from MATLAB functions</a></li> | |
53 <li><a href="ao_create.html#tsfcn">Creating AOs from functions of time</a></li> | |
54 <li><a href="ao_create.html#window">Creating AOs from window functions</a></li> | |
55 <li><a href="ao_create.html#waveform">Creating AOs from waveform descriptions</a></li> | |
56 <li><a href="ao_create.html#pzmodel">Creating AOs from pole zero models</a></li> | |
57 </ul> | |
58 | |
59 <hr> | |
60 <h4><a name="text"></a>Creating AOs from text files.</h4> | |
61 | |
62 <p>Analysis Objects can be created from text files containing two columns of ASCII numbers. Files | |
63 ending in '.txt' or '.dat' will be handled as ASCII file inputs. The | |
64 first column is taken to be the time instances; the second column is taken to be the amplitude | |
65 samples. The created AO is of type <tt>tsdata</tt> with the sample rate set by the difference | |
66 between the time-stamps of the first two samples in the file. The name of the resulting AO is | |
67 set to the filename (without the file extension). The filename is also stored as a parameter in | |
68 the history parameter list. The following code shows this in action:</p> | |
69 | |
70 <div class="fragment"><pre> | |
71 >> a = ao(<span class="string">'data.txt'</span>) | |
72 ----------- ao 01: data.txt_01_02 ----------- | |
73 | |
74 name: data.txt_01_02 | |
75 data: (0,-1.06421341288933) (0.1,1.60345729812004) (0.2,1.23467914689078) ... | |
76 -------- tsdata 01 ------------ | |
77 | |
78 fs: 10 | |
79 x: [100 1], double | |
80 y: [100 1], double | |
81 dx: [0 0], double | |
82 dy: [0 0], double | |
83 xunits: [s] | |
84 yunits: [] | |
85 nsecs: 10 | |
86 t0: 1970-01-01 00:00:00.000 | |
87 ------------------------------- | |
88 | |
89 hist: ao / ao / SId: fromDatafile ... $-->$Id: ao ... S | |
90 mdlfile: empty | |
91 description: | |
92 UUID: e6ccfcb6-da49-4f4c-8c2c-3054fe5d2762 | |
93 --------------------------------------------- | |
94 </pre></div> | |
95 <p>As with most constructor calls, an equivalent action can be achieved using an input | |
96 <a href="plist_intro.html">Parameter List</a>.</p> | |
97 | |
98 <div class="fragment"><pre> | |
99 >> a = ao(plist(<span class="string">'filename'</span>, <span class="string">'data.txt'</span>)) | |
100 </pre></div> | |
101 | |
102 <hr> | |
103 <h4><a name="xml"></a>Creating AOs from XML or .mat files</h4> | |
104 | |
105 <p>AOs can be saved as both XML and .MAT files. As such, they can also be created from these | |
106 files.</p> | |
107 | |
108 <div class="fragment"><pre> | |
109 >> a = ao(<span class="string">'a.xml'</span>) | |
110 ----------- ao 01: a ----------- | |
111 | |
112 name: None | |
113 data: (0,-0.493009815316451) (0.1,-0.180739356415037) (0.2,0.045841105713705) ... | |
114 -------- tsdata 01 ------------ | |
115 | |
116 fs: 10 | |
117 x: [100 1], double | |
118 y: [100 1], double | |
119 dx: [0 0], double | |
120 dy: [0 0], double | |
121 xunits: [s] | |
122 yunits: [] | |
123 nsecs: 10 | |
124 t0: 1970-01-01 00:00:01.000 | |
125 ------------------------------- | |
126 | |
127 hist: ao / ao / SId: fromVals ... $-->$Id: ao ... S | |
128 mdlfile: empty | |
129 description: | |
130 UUID: 2fed6155-6468-4533-88f6-e4b27bc6e1aa | |
131 -------------------------------- | |
132 </pre></div> | |
133 | |
134 <hr> | |
135 <h4><a name="fcn"></a>Creating AOs from MATLAB functions</h4> | |
136 | |
137 <p>AOs can be created from any valid MATLAB function which returns a vector or matrix of values. | |
138 For such calls, a parameter list is used as input. For example, the following code creates | |
139 an AO containing 1000 random numbers:</p> | |
140 | |
141 <div class="fragment"><pre> | |
142 >> a = ao(plist(<span class="string">'fcn'</span>, <span class="string">'randn(1000,1)'</span>)) | |
143 ----------- ao 01: a ----------- | |
144 | |
145 name: None | |
146 data: -1.28325610460477 -2.32895451628334 0.901931466951714 -1.83563868373519 0.06675 ... | |
147 -------- cdata 01 ------------ | |
148 y: [1000x1], double | |
149 dy: [0x0], double | |
150 yunits: [] | |
151 ------------------------------ | |
152 | |
153 hist: ao / ao / SId: fromFcn ... $-->$Id ... $ | |
154 mdlfile: empty | |
155 description: | |
156 UUID: 0072f8d0-f804-472b-a4aa-e9ec6a8de803 | |
157 -------------------------------- | |
158 </pre></div> | |
159 <p>Here you can see that the AO is a <tt>cdata</tt> type and the name is set to be the function | |
160 that was input.</p> | |
161 | |
162 <hr> | |
163 <h4><a name="tsfcn"></a>Creating AOs from functions of time</h4> | |
164 | |
165 <p>AOs can be created from any valid MATLAB function which is a function of the variable | |
166 <tt>t</tt>. For such calls, a parameter list is used as input. For example, the following | |
167 code creates an AO containing sinusoidal signal at 1Hz with some additional Gaussian noise:</p> | |
168 | |
169 <div class="fragment"><pre> | |
170 pl = plist(); | |
171 pl = append(pl, <span class="string">'nsecs'</span>, 100); | |
172 pl = append(pl, <span class="string">'fs'</span>, 10); | |
173 pl = append(pl, <span class="string">'tsfcn'</span>, <span class="string">'sin(2*pi*1*t)+randn(size(t))'</span>); | |
174 a = ao(pl) | |
175 ----------- ao 01: a ----------- | |
176 | |
177 name: None | |
178 data: (0,1.37694916561229) (0.1,-0.820427237640771) (0.2,1.09228819960292) ... | |
179 -------- tsdata 01 ------------ | |
180 | |
181 fs: 10 | |
182 x: [1000 1], double | |
183 y: [1000 1], double | |
184 dx: [0 0], double | |
185 dy: [0 0], double | |
186 xunits: [s] | |
187 yunits: [] | |
188 nsecs: 100 | |
189 t0: 1970-01-01 00:00:00.000 | |
190 ------------------------------- | |
191 | |
192 hist: ao / ao / SId: fromTSfcn ... $-->$Id: ao ... S | |
193 mdlfile: empty | |
194 description: | |
195 UUID: c0f481cf-4bdd-4a91-bc78-6d34f8222313 | |
196 -------------------------------- | |
197 </pre></div> | |
198 <p>Here you can see that the AO is a <tt>tsdata</tt> type, as you would expect. Also note that you | |
199 need to specify the sample rate (<tt>fs</tt>) and the number of seconds of data you would like | |
200 to have (<tt>nsecs</tt>).</p> | |
201 | |
202 <hr> | |
203 <h4><a name="window"></a>Creating AOs from window functions</h4> | |
204 | |
205 <p>The LTPDA Toolbox contains a class for designing spectral windows | |
206 (see <a href="specwin.html">Spectral Windows</a>). A spectral window object can | |
207 also be used to create an Analysis Object as follows:</p> | |
208 | |
209 <div class="fragment"><pre> | |
210 >> w = specwin(<span class="string">'Hanning'</span>, 1000) | |
211 ------ specwin/1 ------- | |
212 type: Hanning | |
213 alpha: 0 | |
214 psll: 31.5 | |
215 rov: 50 | |
216 nenbw: 1.5 | |
217 w3db: 1.4382 | |
218 flatness: -1.4236 | |
219 ws: 500 | |
220 ws2: 375.000000000001 | |
221 win: [0 9.86957193144233e-06 3.94778980919441e-05 8.88238095955174e-05 0.0001579 ... | |
222 version: SId: specwin.m,v 1.67 2009/09/01 09:25:24 ingo Exp S | |
223 ------------------------ | |
224 | |
225 >> a = ao(w) | |
226 ----------- ao 01: ao(Hanning) ----------- | |
227 | |
228 name: ao(Hanning) | |
229 data: 0 9.86957193144233e-06 3.94778980919441e-05 8.88238095955174e-05 0.0001579 ... | |
230 -------- cdata 01 ------------ | |
231 y: [1x1000], double | |
232 dy: [0x0], double | |
233 yunits: [] | |
234 ------------------------------ | |
235 | |
236 hist: ao / ao / SId: fromSpecWin ... $-->$Id: ao ... S | |
237 mdlfile: empty | |
238 description: | |
239 UUID: ea1a9036-b9f5-4bdb-b3a3-211e9d697060 | |
240 ------------------------------------------ | |
241 </pre></div> | |
242 <p> | |
243 It is also possible to pass the information about the window as a plist to the ao constructor. | |
244 </p> | |
245 <div class="fragment"><pre> | |
246 >> ao(plist(<span class="string">'win'</span>, <span class="string">'Hanning'</span>, <span class="string">'length'</span>, 1000)) | |
247 ----------- ao 01: ao(Hanning) ----------- | |
248 | |
249 name: ao(Hanning) | |
250 data: 0 9.86957193144233e-06 3.94778980919441e-05 8.88238095955174e-05 0.0001579 ... | |
251 -------- cdata 01 ------------ | |
252 y: [1x1000], double | |
253 dy: [0x0], double | |
254 yunits: [] | |
255 ------------------------------ | |
256 | |
257 hist: ao / ao / SId: fromSpecWin ... -->$Id: ao ... S | |
258 mdlfile: empty | |
259 description: | |
260 UUID: 5b81f67a-45b9-43f8-a74a-bc5161fd718f | |
261 ------------------------------------------ | |
262 </pre></div> | |
263 | |
264 <p> | |
265 The example code above creates a Hanning window object with 1000 points. The call to the AO | |
266 constructor then creates a <tt>cdata</tt> type AO with 1000 points. This AO can then be multiplied | |
267 against other AOs in order to window the data. | |
268 </p> | |
269 | |
270 <hr> | |
271 <h4><a name="waveform"></a>Creating AOs from waveform descriptions</h4> | |
272 | |
273 <p> | |
274 MATLAB contains various functions for creating different waveforms, for example, | |
275 <tt>square</tt>, <tt>sawtooth</tt>. Some of these functions can be called upon to create | |
276 Analysis Objects. The following code creates an AO with a sawtooth waveform: | |
277 </p> | |
278 | |
279 <div class="fragment"><pre> | |
280 pl = plist(); | |
281 pl = append(pl, <span class="string">'fs'</span>, 100); | |
282 pl = append(pl, <span class="string">'nsecs'</span>, 5); | |
283 pl = append(pl, <span class="string">'waveform'</span>, 'Sawtooth'); | |
284 pl = append(pl, <span class="string">'f'</span>, 1); | |
285 pl = append(pl, <span class="string">'width'</span>, 0.5); | |
286 | |
287 asaw = ao(pl) | |
288 ----------- ao 01: Sawtooth ----------- | |
289 | |
290 name: Sawtooth | |
291 data: (0,-1) (0.01,-0.96) (0.02,-0.92) (0.03,-0.88) (0.04,-0.84) ... | |
292 -------- tsdata 01 ------------ | |
293 | |
294 fs: 100 | |
295 x: [500 1], double | |
296 y: [500 1], double | |
297 dx: [0 0], double | |
298 dy: [0 0], double | |
299 xunits: [s] | |
300 yunits: [] | |
301 nsecs: 5 | |
302 t0: 1970-01-01 00:00:00.000 | |
303 ------------------------------- | |
304 | |
305 hist: ao / ao / SId: fromWaveform ... $-->$Id: ao ... S | |
306 mdlfile: empty | |
307 description: | |
308 UUID: cb76c866-ee3f-47e6-bb29-290074666e43 | |
309 --------------------------------------- | |
310 </pre></div> | |
311 <p> | |
312 You can call the <tt>iplot</tt> function to view the resulting waveform: | |
313 </p> | |
314 <div class="fragment"><pre> | |
315 iplot(asaw); | |
316 </pre></div> | |
317 <img src="images/ao_create_sawtooth.png" alt="Sawtooth waveform" border="3" width="600px"> | |
318 | |
319 <hr> | |
320 <h4><a name="pzmodel"></a>Creating AOs from pole zero models</h4> | |
321 | |
322 <p> | |
323 When generating an AO from a pole zero model, the noise generator function is called. | |
324 This a method to generate arbitrarily long time series with a prescribed spectral density. | |
325 The algorithm is based on the following paper: | |
326 </p> | |
327 <p>Franklin, Joel N.: | |
328 <i> Numerical simulation of stationary and non-stationary gaussian | |
329 random processes </i>, SIAM review, Volume {<b> 7</b>}, Issue 1, page 68--80, 1965. | |
330 </p> | |
331 <p> | |
332 The Document <i> Generation of Random time series with prescribed spectra </i> by Gerhard Heinzel (S2-AEI-TN-3034) <br> corrects a mistake in the aforesaid paper and describes the practical implementation. | |
333 The following code creates an AO with a time series having a prescribed spectral density, | |
334 defined by the input pole zero model: | |
335 </p> | |
336 | |
337 <div class="fragment"><pre> | |
338 f1 = 5; | |
339 f2 = 10; | |
340 f3 = 1; | |
341 gain = 1; | |
342 fs = 10; <span class="comment">%sampling frequancy</span> | |
343 nsecs = 100; <span class="comment">%number of seconds to be generated</span> | |
344 | |
345 p = [pz(f1) pz(f2)]; | |
346 z = [pz(f3)]; | |
347 pzm = pzmodel(gain, p, z); | |
348 a = ao(pzm, nsecs, fs) | |
349 ----------- ao 01: noisegen(None) ----------- | |
350 | |
351 name: noisegen(None) | |
352 data: (0,9.20287001568168) (0.1,-3.88425345108961) (0.2,6.31042718242658) ... | |
353 -------- tsdata 01 ------------ | |
354 | |
355 fs: 10 | |
356 x: [1000 1], double | |
357 y: [1000 1], double | |
358 dx: [0 0], double | |
359 dy: [0 0], double | |
360 xunits: [s] | |
361 yunits: [] | |
362 nsecs: 100 | |
363 t0: 1970-01-01 00:00:00.000 | |
364 ------------------------------- | |
365 | |
366 hist: ao / ao / SId: fromPzmodel ... $-->$Id: ao ... S | |
367 mdlfile: empty | |
368 description: | |
369 UUID: 4a89d910-8672-475f-91cd-4fcc4b52a6b4 | |
370 --------------------------------------------- | |
371 </pre></div> | |
372 <p> | |
373 You can call the <tt>iplot</tt> function to view the resulting noise. | |
374 </p> | |
375 <div class="fragment"><pre> | |
376 iplot(a); | |
377 </pre></div> | |
378 <img src="images/ao_create_niose.png" alt="Random time series" border="3" width="600px"> | |
379 | |
380 | |
381 </p> | |
382 | |
383 <br> | |
384 <br> | |
385 <table class="nav" summary="Navigation aid" border="0" width= | |
386 "100%" cellpadding="0" cellspacing="0"> | |
387 <tr valign="top"> | |
388 <td align="left" width="20"><a href="ao_intro.html"><img src= | |
389 "b_prev.gif" border="0" align="bottom" alt= | |
390 "Analysis Objects"></a> </td> | |
391 | |
392 <td align="left">Analysis Objects</td> | |
393 | |
394 <td> </td> | |
395 | |
396 <td align="right">Saving Analysis Objects</td> | |
397 | |
398 <td align="right" width="20"><a href= | |
399 "ao_save.html"><img src="b_next.gif" border="0" align= | |
400 "bottom" alt="Saving Analysis Objects"></a></td> | |
401 </tr> | |
402 </table><br> | |
403 | |
404 <p class="copy">©LTP Team</p> | |
405 </body> | |
406 </html> |