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