3294
|
1 @c Copyright (C) 1996, 1997 John W. Eaton |
|
2 @c This is part of the Octave manual. |
|
3 @c For copying conditions, see the file gpl.texi. |
|
4 |
|
5 @node Signal Processing, Image Processing, Control Theory, Top |
|
6 @chapter Signal Processing |
|
7 |
|
8 I hope that someday Octave will include more signal processing |
|
9 functions. If you would like to help improve Octave in this area, |
|
10 please contact @email{bug-octave@@bevo.che.wisc.edu}. |
|
11 |
|
12 @deftypefn {Function File} {} detrend (@var{x}, @var{p}) |
|
13 If @var{x} is a vector, @code{detrend (@var{x}, @var{p})} removes the |
|
14 best fit of a polynomial of order @var{p} from the data @var{x}. |
|
15 |
|
16 If @var{x} is a matrix, @code{detrend (@var{x}, @var{p})} does the same |
|
17 for each column in @var{x}. |
|
18 |
|
19 The second argument is optional. If it is not specified, a value of 1 |
|
20 is assumed. This corresponds to removing a linear trend. |
|
21 @end deftypefn |
|
22 |
|
23 @deftypefn {Function} {} fft (@var{a}, @var{n}) |
|
24 Compute the FFT of @var{a} using subroutines from @sc{Fftpack}. If @var{a} |
|
25 is a matrix, @code{fft} computes the FFT for each column of @var{a}. |
|
26 |
|
27 If called with two arguments, @var{n} is expected to be an integer |
|
28 specifying the number of elements of @var{a} to use. If @var{a} is a |
|
29 matrix, @var{n} specifies the number of rows of @var{a} to use. If |
|
30 @var{n} is larger than the size of @var{a}, @var{a} is resized and |
|
31 padded with zeros. |
|
32 @end deftypefn |
|
33 |
|
34 @deftypefn {Loadable Function} {} ifft (@var{a}, @var{n}) |
|
35 Compute the inverse FFT of @var{a} using subroutines from @sc{Fftpack}. If |
|
36 @var{a} is a matrix, @code{fft} computes the inverse FFT for each column |
|
37 of @var{a}. |
|
38 |
|
39 If called with two arguments, @var{n} is expected to be an integer |
|
40 specifying the number of elements of @var{a} to use. If @var{a} is a |
|
41 matrix, @var{n} specifies the number of rows of @var{a} to use. If |
|
42 @var{n} is larger than the size of @var{a}, @var{a} is resized and |
|
43 padded with zeros. |
|
44 @end deftypefn |
|
45 |
|
46 @deftypefn {Loadable Function} {} fft2 (@var{a}, @var{n}, @var{m}) |
|
47 Compute the two dimensional FFT of @var{a}. |
|
48 |
|
49 The optional arguments @var{n} and @var{m} may be used specify the |
|
50 number of rows and columns of @var{a} to use. If either of these is |
|
51 larger than the size of @var{a}, @var{a} is resized and padded with |
|
52 zeros. |
|
53 @end deftypefn |
|
54 |
|
55 @deftypefn {Loadable Function} {} ifft2 (@var{a}, @var{n}, @var{m}) |
|
56 Compute the two dimensional inverse FFT of @var{a}. |
|
57 |
|
58 The optional arguments @var{n} and @var{m} may be used specify the |
|
59 number of rows and columns of @var{a} to use. If either of these is |
|
60 larger than the size of @var{a}, @var{a} is resized and padded with |
|
61 zeros. |
|
62 @end deftypefn |
|
63 |
|
64 @deftypefn {Built-in Function} {} fftconv (@var{a}, @var{b}, @var{n}) |
|
65 Return the convolution of the vectors @var{a} and @var{b}, as a vector |
|
66 with length equal to the @code{length (a) + length (b) - 1}. If @var{a} |
|
67 and @var{b} are the coefficient vectors of two polynomials, the returned |
|
68 value is the coefficient vector of the product polynomial. |
|
69 |
|
70 The computation uses the FFT by calling the function @code{fftfilt}. If |
|
71 the optional argument @var{n} is specified, an N-point FFT is used. |
|
72 @end deftypefn |
|
73 |
|
74 @deftypefn {Function File} {} fftfilt (@var{b}, @var{x}, @var{n}) |
|
75 |
|
76 With two arguments, @code{fftfilt} filters @var{x} with the FIR filter |
|
77 @var{b} using the FFT. |
|
78 |
|
79 Given the optional third argument, @var{n}, @code{fftfilt} uses the |
|
80 overlap-add method to filter @var{x} with @var{b} using an N-point FFT. |
|
81 @end deftypefn |
|
82 |
|
83 @deftypefn {Loadable Function} {y =} filter (@var{b}, @var{a}, @var{x}) |
|
84 Return the solution to the following linear, time-invariant difference |
|
85 equation: |
|
86 @iftex |
|
87 @tex |
|
88 $$ |
|
89 \sum_{k=0}^N a_{k+1} y_{n-k} = \sum_{k=0}^M b_{k+1} x_{n-k}, \qquad |
|
90 1 \le n \le P |
|
91 $$ |
|
92 @end tex |
|
93 @end iftex |
|
94 @ifinfo |
|
95 |
|
96 @smallexample |
|
97 N M |
|
98 SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x) |
|
99 k=0 k=0 |
|
100 @end smallexample |
|
101 @end ifinfo |
|
102 |
|
103 @noindent |
|
104 where |
|
105 @ifinfo |
|
106 N=length(a)-1 and M=length(b)-1. |
|
107 @end ifinfo |
|
108 @iftex |
|
109 @tex |
|
110 $a \in \Re^{N-1}$, $b \in \Re^{M-1}$, and $x \in \Re^P$. |
|
111 @end tex |
|
112 @end iftex |
|
113 An equivalent form of this equation is: |
|
114 @iftex |
|
115 @tex |
|
116 $$ |
|
117 y_n = -\sum_{k=1}^N c_{k+1} y_{n-k} + \sum_{k=0}^M d_{k+1} x_{n-k}, \qquad |
|
118 1 \le n \le P |
|
119 $$ |
|
120 @end tex |
|
121 @end iftex |
|
122 @ifinfo |
|
123 |
|
124 @smallexample |
|
125 N M |
|
126 y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x) |
|
127 k=1 k=0 |
|
128 @end smallexample |
|
129 @end ifinfo |
|
130 |
|
131 @noindent |
|
132 where |
|
133 @ifinfo |
|
134 c = a/a(1) and d = b/a(1). |
|
135 @end ifinfo |
|
136 @iftex |
|
137 @tex |
|
138 $c = a/a_1$ and $d = b/a_1$. |
|
139 @end tex |
|
140 @end iftex |
|
141 |
|
142 In terms of the z-transform, y is the result of passing the discrete- |
|
143 time signal x through a system characterized by the following rational |
|
144 system function: |
|
145 @iftex |
|
146 @tex |
|
147 $$ |
|
148 H(z) = {\displaystyle\sum_{k=0}^M d_{k+1} z^{-k} |
|
149 \over 1 + \displaystyle\sum_{k+1}^N c_{k+1} z^{-k}} |
|
150 $$ |
|
151 @end tex |
|
152 @end iftex |
|
153 @ifinfo |
|
154 |
|
155 @example |
|
156 M |
|
157 SUM d(k+1) z^(-k) |
|
158 k=0 |
|
159 H(z) = ---------------------- |
|
160 N |
|
161 1 + SUM c(k+1) z(-k) |
|
162 k=1 |
|
163 @end example |
|
164 @end ifinfo |
|
165 @end deftypefn |
|
166 |
|
167 @deftypefn {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si}) |
|
168 This is the same as the @code{filter} function described above, except |
|
169 that @var{si} is taken as the initial state of the system and the final |
|
170 state is returned as @var{sf}. The state vector is a column vector |
|
171 whose length is equal to the length of the longest coefficient vector |
|
172 minus one. If @var{si} is not set, the initial state vector is set to |
|
173 all zeros. |
|
174 @end deftypefn |
|
175 |
|
176 @deftypefn {Function File} {[@var{h}, @var{w}] =} freqz (@var{b}, @var{a}, @var{n}, "whole") |
|
177 Return the complex frequency response @var{h} of the rational IIR filter |
|
178 whose numerator and denominator coefficients are @var{b} and @var{a}, |
|
179 respectively. The response is evaluated at @var{n} angular frequencies |
|
180 between 0 and |
|
181 @ifinfo |
|
182 2*pi. |
|
183 @end ifinfo |
|
184 @iftex |
|
185 @tex |
|
186 $2\pi$. |
|
187 @end tex |
|
188 @end iftex |
|
189 |
|
190 @noindent |
|
191 The output value @var{w} is a vector of the frequencies. |
|
192 |
|
193 If the fourth argument is omitted, the response is evaluated at |
|
194 frequencies between 0 and |
|
195 @ifinfo |
|
196 pi. |
|
197 @end ifinfo |
|
198 @iftex |
|
199 @tex |
|
200 $\pi$. |
|
201 @end tex |
|
202 @end iftex |
|
203 |
|
204 If @var{n} is omitted, a value of 512 is assumed. |
|
205 |
|
206 If @var{a} is omitted, the denominator is assumed to be 1 (this |
|
207 corresponds to a simple FIR filter). |
|
208 |
|
209 For fastest computation, @var{n} should factor into a small number of |
|
210 small primes. |
|
211 @end deftypefn |
|
212 |
|
213 @deftypefn {Function File} {} sinc (@var{x}) |
|
214 Return |
|
215 @iftex |
|
216 @tex |
|
217 $ \sin (\pi x)/(\pi x)$. |
|
218 @end tex |
|
219 @end iftex |
|
220 @ifinfo |
|
221 sin(pi*x)/(pi*x). |
|
222 @end ifinfo |
|
223 @end deftypefn |