1 <?xml version="1.0" encoding="UTF-8"?>
3     <refnamediv>
4         <refname>remezb</refname>
5         <refpurpose>Minimax approximation of magnitude response</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>Calling Sequence</title>
9         <synopsis>[an]=remezb(nc,fg,ds,wt)</synopsis>
10     </refsynopsisdiv>
11     <refsection>
12         <title>Arguments</title>
13         <variablelist>
14             <varlistentry>
15                 <term>nc</term>
16                 <listitem>
17                     <para>Number of cosine functions</para>
18                 </listitem>
19             </varlistentry>
20             <varlistentry>
21                 <term>fg</term>
22                 <listitem>
23                     <para>Grid of frequency points in [0,.5)</para>
24                 </listitem>
25             </varlistentry>
26             <varlistentry>
27                 <term>ds</term>
28                 <listitem>
29                     <para>
30                         Desired magnitude on grid <literal>fg</literal>
31                     </para>
32                 </listitem>
33             </varlistentry>
34             <varlistentry>
35                 <term>wt</term>
36                 <listitem>
37                     <para>
38                         Weighting function on error on grid <literal>fg</literal>
39                     </para>
40                 </listitem>
41             </varlistentry>
42             <varlistentry>
43                 <term>an</term>
44                 <listitem>
45                     <para>Cosine filter coefficients</para>
46                 </listitem>
47             </varlistentry>
48         </variablelist>
49     </refsection>
50     <refsection>
51         <title>Description</title>
52         <para>
53             Minimax approximation of a frequency domain
54             magnitude response. The approximation takes
55             the form <literal>h = sum[a(n)*cos(wn)]</literal>
56             for n=0,1,...,nc. An FIR, linear-phase filter
57             can be obtained from the output of the function
58             by using the following commands
59         </para>
60         <programlisting role="no-scilab-exec"><![CDATA[
61 hn(1:nc-1)=an(nc:-1:2)/2;
62 hn(nc)=an(1);
63 hn(nc+1:2*nc-1)=an(2:nc)/2;
64  ]]></programlisting>
65     </refsection>
66     <refsection>
67         <title>Examples</title>
68         <programlisting role="example"><![CDATA[
69 // Choose the number of cosine functions and create a dense grid
70 // in [0,.24) and [.26,.5)
71 nc=21;ngrid=nc*16;
72 fg=.24*(0:ngrid/2-1)/(ngrid/2-1);
73 fg(ngrid/2+1:ngrid)=fg(1:ngrid/2)+.26*ones(1:ngrid/2);
75 // Specify a low pass filter magnitude for the desired response
76 ds(1:ngrid/2)=ones(1:ngrid/2);
77 ds(ngrid/2+1:ngrid)=zeros(1:ngrid/2);
79 // Specify a uniform weighting function
80 wt=ones(fg);
82 // Run remezb
83 an=remezb(nc,fg,ds,wt)
85 // Make a linear phase FIR filter
86 hn(1:nc-1)=an(nc:-1:2)/2;
87 hn(nc)=an(1);
88 hn(nc+1:2*nc-1)=an(2:nc)/2;
90 // Plot the filter's magnitude response
91 plot(.5*(0:255)/256,frmag(hn,256));
93 // Choose the number of cosine functions and create a dense grid in [0,.5)
94 nc=21; ngrid=nc*16;
95 fg=.5*(0:(ngrid-1))/ngrid;
97 // Specify a triangular shaped magnitude for the desired response
98 ds(1:ngrid/2)=(0:ngrid/2-1)/(ngrid/2-1);
99 ds(ngrid/2+1:ngrid)=ds(ngrid/2:-1:1);
101 // Specify a uniform weighting function
102 wt=ones(fg);
104 // Run remezb
105 an=remezb(nc,fg,ds,wt)
107 // Make a linear phase FIR filter
108 hn(1:nc-1)=an(nc:-1:2)/2;
109 hn(nc)=an(1);
110 hn(nc+1:2*nc-1)=an(2:nc)/2;
112 // Plot the filter's magnitude response
113 plot(.5*(0:255)/256,frmag(hn,256));
114  ]]></programlisting>
116 <scilab:image>
117 nc=21;ngrid=nc*16;
118 fg=.24*(0:ngrid/2-1)/(ngrid/2-1);
119 fg(ngrid/2+1:ngrid)=fg(1:ngrid/2)+.26*ones(1:ngrid/2);
121 ds(1:ngrid/2)=ones(1:ngrid/2);
122 ds(ngrid/2+1:ngrid)=zeros(1:ngrid/2);
124 wt=ones(fg);
126 an=remezb(nc,fg,ds,wt)
128 hn(1:nc-1)=an(nc:-1:2)/2;
129 hn(nc)=an(1);
130 hn(nc+1:2*nc-1)=an(2:nc)/2;
132 plot(.5*(0:255)/256,frmag(hn,256));
134 nc=21; ngrid=nc*16;
135 fg=.5*(0:(ngrid-1))/ngrid;
137 ds(1:ngrid/2)=(0:ngrid/2-1)/(ngrid/2-1);
138 ds(ngrid/2+1:ngrid)=ds(ngrid/2:-1:1);
140 wt=ones(fg);
142 an=remezb(nc,fg,ds,wt)
144 hn(1:nc-1)=an(nc:-1:2)/2;
145 hn(nc)=an(1);
146 hn(nc+1:2*nc-1)=an(2:nc)/2;
148 plot(.5*(0:255)/256,frmag(hn,256));
149 </scilab:image>
150     </refsection>
151     <refsection role="see also">
152         <title>See Also</title>
153         <simplelist type="inline">
154             <member>