3431
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {[@var{wmin}, @var{wmax}] =} bode_bounds (@var{zer}, @var{pol}, @var{dflg}@{, @var{tsam} @}) |
|
21 ## Get default range of frequencies based on cutoff frequencies of system |
|
22 ## poles and zeros. |
|
23 ## Frequency range is the interval [10^wmin,10^wmax] |
|
24 ## |
|
25 ## Used internally in freqresp (@code{bode}, @code{nyquist}) |
|
26 ## @end deftypefn |
|
27 |
|
28 function [wmin, wmax] = bode_bounds (zer, pol, DIGITAL, tsam) |
|
29 |
|
30 ## make sure zer,pol are row vectors |
|
31 if(!isempty(pol)) pol = reshape(pol,1,length(pol)); endif |
|
32 if(!isempty(zer)) zer = reshape(zer,1,length(zer)); endif |
|
33 |
|
34 ## check for natural frequencies away from omega = 0 |
|
35 if (DIGITAL) |
|
36 ## The 2nd conditions prevents log(0) in the next log command |
|
37 iiz = find(abs(zer - 1) > norm(zer) * eps && abs(zer) > norm(zer) * eps); |
|
38 iip = find(abs(pol - 1) > norm(pol) * eps && abs(pol) > norm(pol) * eps); |
|
39 |
|
40 ## avoid dividing empty matrices, it would work but looks nasty |
|
41 if (!isempty(iiz)) czer = log(zer(iiz))/tsam; |
|
42 else czer = []; endif |
|
43 |
|
44 if (!isempty(iip)) cpol = log(pol(iip))/tsam; |
|
45 else cpol = []; endif |
|
46 |
|
47 else |
|
48 ## continuous |
|
49 iip = find((abs(pol)) > (norm(pol) * eps)); |
|
50 iiz = find((abs(zer)) > (norm(zer) * eps)); |
|
51 |
|
52 if(!isempty(zer)) czer = zer(iiz); |
|
53 else czer = []; endif |
|
54 if(!isempty(pol)) cpol = pol(iip); |
|
55 else cpol = []; endif |
|
56 endif |
|
57 |
|
58 if(max(size(iip)) + max(size(iiz)) ) |
|
59 wmin = floor(log10(min(abs([cpol,czer])))); |
|
60 wmax = ceil(log10(max(abs([cpol,czer])))); |
|
61 else |
|
62 ## no poles/zeros away from omega = 0; pick defaults |
|
63 wmin = -1; |
|
64 wmax = 3; |
|
65 endif |
|
66 |
|
67 ## expand to show the entirety of the "interesting" portion of the plot |
|
68 wmin--; |
|
69 wmax++; |
|
70 |
|
71 ## run digital frequency all the way to pi |
|
72 if (DIGITAL) wmax = log10(pi/tsam); endif |
|
73 |
|
74 endfunction |