File: pspect.xml

package info (click to toggle)
scilab 6.0.1-10%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 365,292 kB
  • sloc: xml: 827,376; cpp: 273,125; ansic: 216,672; java: 190,706; fortran: 90,783; ml: 24,107; tcl: 16,853; sh: 13,608; makefile: 9,556; lex: 1,615; perl: 1,566; yacc: 1,263; php: 690; cs: 614
file content (362 lines) | stat: -rw-r--r-- 17,698 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<?xml version="1.0" encoding="UTF-8"?>
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
          xmlns:scilab="http://www.scilab.org" xml:id="pspect" xml:lang="en">
    <refnamediv>
        <refname>pspect</refname>
        <refpurpose>two sided cross-spectral estimate between 2 discrete time signals using
            the Welch's average periodogram method.
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
            [sm [,cwp]]=pspect(sec_step,sec_leng,wtype,x [,y] [,wpar])
            [sm [,cwp]]=pspect(sec_step,sec_leng,wtype,nx [,ny] [,wpar])
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>x</term>
                <listitem>
                    <para>vector, the time-domain samples of the first signal.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>y</term>
                <listitem>
                    <para>
                        vector, the time-domain samples of the second signal. If <literal>y</literal>
                        is omitted it is supposed to be equal to <literal>x</literal>
                        (auto-correlation). If it is present, it must have the same number of
                        element than <literal>x</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>nx</term>
                <listitem>
                    <para>
                        a scalar : the number of samples in the <literal>x</literal>
                        signal. In this case the segments of the <literal>x</literal> signal are loaded by a
                        user defined function named <literal>getx</literal> (see
                        below).
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>ny</term>
                <listitem>
                    <para>a scalar : the number of samples in the
                        <literal>y</literal> signal. In this case the segments of
                        the y signal are loaded by a user defined function named
                        <literal>gety</literal> (see below). If present
                        <literal>ny</literal> must be equal to
                        <literal>nx</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>sec_step</term>
                <listitem>
                    <para>
                        offset of each data window. The overlap <literal>D
                        </literal>
                        is given by sec_leng -sec_step<literal>. if
                            sec_step==sec_leng/2
                        </literal>
                        50% overlap is made. The
                        overlap
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>sec_leng</term>
                <listitem>
                    <para>Number of points of the window.</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>wtype</term>
                <listitem>
                    <para>The window type</para>
                    <itemizedlist>
                        <listitem>
                            <para>
                                <literal>'re'</literal>: rectangular
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                <literal>'tr'</literal>: triangular
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                <literal>'hm'</literal>: Hamming
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                <literal>'hn'</literal>: Hann
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                <literal>'kr'</literal>: Kaiser,in this case the wpar
                                argument must be given
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                <literal>'ch'</literal>: Chebyshev, in this case the wpar
                                argument must be given
                            </para>
                        </listitem>
                    </itemizedlist>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>wpar</term>
                <listitem>
                    <para>
                        optional parameters for <literal>Kaiser and Chebyshev
                            windows:
                        </literal>
                    </para>
                    <itemizedlist>
                        <listitem>
                            <para>
                                'kr': <literal>wpar must be a strictly positive
                                    number
                                </literal>
                            </para>
                        </listitem>
                        <listitem>
                            <para>
                                'ch': <literal>wpar</literal> must be a 2 element vector
                                <literal> [main_lobe_width,side_lobe_height]with
                                </literal>
                                <literal>0&lt;main_lobe_width&lt;.5</literal>, and
                                <literal>side_lobe_height&gt;0</literal>
                            </para>
                        </listitem>
                    </itemizedlist>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>sm</term>
                <listitem>
                    <para>
                        Two sided power spectral estimate in the interval <literal>[0,1]</literal> of the
                        normalized frequencies. It is a row array with  <literal>sec_len</literal>
                        elements . The array is real in case of auto-correlation and
                        complex in case of cross-correlation.
                    </para>
                    <para>The associated normalized frequencies array is
                        <literal>linspace(0,1,sec_len)</literal>.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>cwp</term>
                <listitem>
                    <para>unspecified Chebyshev window parameter in case of Chebyshev
                        windowing, or an empty matrix.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>Computes the cross-spectrum estimate of two signals
            <literal>x</literal> and <literal>y</literal> if both are given and the
            auto-spectral estimate of <literal>x</literal> otherwise. Spectral
            estimate obtained using the modified periodogram method.
        </para>
        <para>
            The cross spectrum of two signal <literal>x</literal> and  <literal>y</literal> is defined to be
        </para>
        <para>
            <inlinemediaobject>
                <imageobject>
                    <imagedata>
                        <mml:math>
                            <mml:semantics>
                                <mml:mrow>
                                    <mml:msub>
                                        <mml:mi>S</mml:mi>
                                        <mml:mi mml:fontstyle="italic">xy</mml:mi>
                                    </mml:msub>
                                    <mml:mrow>
                                        <mml:mrow>
                                            <mml:mo mml:stretchy="false">(</mml:mo>
                                            <mml:mo mml:stretchy="false">ω</mml:mo>
                                            <mml:mo mml:stretchy="false">)</mml:mo>
                                        </mml:mrow>
                                        <mml:mo mml:stretchy="false">=</mml:mo>
                                        <mml:mfrac>
                                            <mml:mn>1</mml:mn>
                                            <mml:mi>N</mml:mi>
                                        </mml:mfrac>
                                    </mml:mrow>
                                    <mml:mrow>
                                        <mml:mo mml:stretchy="false">(</mml:mo>
                                        <mml:mrow>
                                            <mml:mrow>
                                                <mml:munderover>
                                                    <mml:mo mml:stretchy="false">∑</mml:mo>
                                                    <mml:mrow>
                                                        <mml:mi>n</mml:mi>
                                                        <mml:mo mml:stretchy="false">=</mml:mo>
                                                        <mml:mn>0</mml:mn>
                                                    </mml:mrow>
                                                    <mml:mrow>
                                                        <mml:mi>N</mml:mi>
                                                        <mml:mo mml:stretchy="false">−</mml:mo>
                                                        <mml:mn>1</mml:mn>
                                                    </mml:mrow>
                                                </mml:munderover>
                                                <mml:mi>x</mml:mi>
                                            </mml:mrow>
                                            <mml:mrow>
                                                <mml:mo mml:stretchy="false">(</mml:mo>
                                                <mml:mi>n</mml:mi>
                                                <mml:mo mml:stretchy="false">)</mml:mo>
                                            </mml:mrow>
                                            <mml:msup>
                                                <mml:mi>e</mml:mi>
                                                <mml:mrow>
                                                    <mml:mrow>
                                                        <mml:mo mml:stretchy="false">−</mml:mo>
                                                        <mml:mi>i</mml:mi>
                                                    </mml:mrow>
                                                    <mml:mo mml:stretchy="false">ω</mml:mo>
                                                    <mml:mi>n</mml:mi>
                                                </mml:mrow>
                                            </mml:msup>
                                        </mml:mrow>
                                        <mml:mo mml:stretchy="false">)</mml:mo>
                                    </mml:mrow>
                                    <mml:mrow>
                                        <mml:mo mml:stretchy="false">(</mml:mo>
                                        <mml:mrow>
                                            <mml:mrow>
                                                <mml:munderover>
                                                    <mml:mo mml:stretchy="false">∑</mml:mo>
                                                    <mml:mrow>
                                                        <mml:mi>n</mml:mi>
                                                        <mml:mo mml:stretchy="false">=</mml:mo>
                                                        <mml:mn>0</mml:mn>
                                                    </mml:mrow>
                                                    <mml:mrow>
                                                        <mml:mi>N</mml:mi>
                                                        <mml:mo mml:stretchy="false">−</mml:mo>
                                                        <mml:mn>1</mml:mn>
                                                    </mml:mrow>
                                                </mml:munderover>
                                                <mml:mover mml:accent="true">
                                                    <mml:mi>y</mml:mi>
                                                    <mml:mo mml:stretchy="false">ˉ</mml:mo>
                                                </mml:mover>
                                            </mml:mrow>
                                            <mml:mrow>
                                                <mml:mo mml:stretchy="false">(</mml:mo>
                                                <mml:mi>n</mml:mi>
                                                <mml:mo mml:stretchy="false">)</mml:mo>
                                            </mml:mrow>
                                            <mml:msup>
                                                <mml:mi>e</mml:mi>
                                                <mml:mrow>
                                                    <mml:mi>i</mml:mi>
                                                    <mml:mo mml:stretchy="false">ω</mml:mo>
                                                    <mml:mi>n</mml:mi>
                                                </mml:mrow>
                                            </mml:msup>
                                        </mml:mrow>
                                        <mml:mo mml:stretchy="false">)</mml:mo>
                                    </mml:mrow>
                                </mml:mrow>
                                <mml:annotation mml:encoding="StarMath 5.0"> S_{xy}(%omega)={1}
                                    over {N} (sum from{n=0} to{N-1} x(n)e^{-i %omega n}) ( sum
                                    from{n=0} to{N-1} bar y(n)e^{i %omega n})
                                </mml:annotation>
                            </mml:semantics>
                        </mml:math>
                    </imagedata>
                </imageobject>
            </inlinemediaobject>
        </para>
        <para>The modified periodogram method of spectral estimation repeatedly
            calculates the periodogram of windowed sub-sections of the data contained
            in <literal>x</literal> and <literal>y</literal> . These periodograms are
            then averaged together and normalized by an appropriate constant to obtain
            the final spectral estimate. It is the averaging process which reduces the
            variance in the estimate.
        </para>
        <para>
            For batch processing, the <literal>x</literal> and
            <literal>y</literal> data may be read segment by segment using the
            <literal>getx </literal>and <literal>gety</literal> user defined
            functions. These functions have the following syntax:
        </para>
        <para>
            <literal>xk=getx(ns,offset)</literal> and
            <literal>yk=gety(ns,offset)</literal> where <literal>ns</literal> is the
            segment size and <literal>offset</literal> is the index of the first
            element of the segment in the full signal.
        </para>
    </refsection>
    <refsection>
        <title>Reference</title>
        <para>Oppenheim, A.V., and R.W. Schafer. Discrete-Time Signal Processing,
            Upper Saddle River, NJ: Prentice-Hall, 1999
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
rand('normal');rand('seed',0);
x=rand(1:1024-33+1);

//make low-pass filter with eqfir
nf=33;bedge=[0 .1;.125 .5];des=[1 0];wate=[1 1];
h=eqfir(nf,bedge,des,wate);

//filter white data to obtain colored data
h1=[h 0*ones(1:max(size(x))-1)];
x1=[x 0*ones(1:max(size(h))-1)];
hf=fft(h1,-1); xf=fft(x1,-1);y=real(fft(hf.*xf,1));

//plot magnitude of filter
h2=[h 0*ones(1:968)];hf2=fft(h2,-1);hf2=real(hf2.*conj(hf2));
hsize=max(size(hf2));fr=(1:hsize)/hsize;plot(fr,log(hf2));

//pspect example
sm=pspect(100,200,'tr',y);smsize=max(size(sm));fr=(1:smsize)/smsize;
plot(fr,log(sm));
rand('unif');
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="cspect">cspect</link>
            </member>
            <member>
                <link linkend="pspect">pspect</link>
            </member>
            <member>
                <link linkend="mese">mese</link>
            </member>
            <member>
                <link linkend="window">window</link>
            </member>
        </simplelist>
    </refsection>
</refentry>