C # include "iirbcf."
C # include "gainc."
Int main (int arg c, char * argv [])
{
Int I, k, n, ns;
[50] double a, b, [50] x [1000], [1000] y;
Double f1, f2, f3 and f4, fs, FLC, FLS, FHC, the FHS, freq, db.
Char fname [40].
The FILE * fp.
The db=50;
Ns=2;
n=4;
FLC=10;
FHC=500;
F1=0;
F2=FLC;
F3=FHC;
F4=0;
Fs=2000;
F1=f1/fs.
F2=f2/fs.
F3=f3/fs.
F4=f4/fs.
Iirbcfpass (ns, n, f1, f2, f3 and f4, db, b, a);
For (k=0; K
Printf (" \ nsection % d \ n \ n ", k + 1);
for (i=0; i<=n; I++)
{
Printf (" b [% d] [% d]=% 10.7 if ", k, I, b [k * (n + 1) +] I);
If (((I % 2==0) & amp; & (I!
=0))){
printf("\n");
}
}
printf("\n");
}
Printf (" \ nenter file name f magnitude response \ n ");
The scanf (" % s, fname ");
If ((fp=fopen (fname, "w"))==NULL)
{
Printf (" always open the file % s \ n ", fname);
exit(0);
}
Gainc (b, a, n, ns, x, y, 1000, 2);
for (i=0; i<100; I++)
{
Freq=I * 0.5/1000.0;
Fprintf (fp, "% % if the if \ n", freq, x [I]);
}
fclose(fp);
}
CodePudding user response:
iirbcfpass
The code is not complete, where the definition of this function?
CodePudding user response:
# include & lt; Stdio. H># include "math. H"
The static void BWTF (ln, l, n, k, d, c);
The static void FBLT (d, c, n, FLN, FHN, b, a);
The static double combin (i1, i2);
The static void bilinear (d, c, b, a, n);
Void iirbcfpass (ns, n, f1, f2, f3 and f4, db, b, a)
Double b [], a [], f1, f2, f3, f4, db.
Int ns, n;
{
int k;
Double omega, lambda, esslon, fl, fh;//bandpass need not omega; Lambda. Warp (); Bpsub (); Omin (), cosh1 ()
Void BWTF ();
Double cosh1 (), warp (), bpsub (), omin ();
Void FBLT ();
Fl=f2;
Fh=f3;
For (k=0; K
BWTF (2 * ns, k, 4, b, a); Normalized L//o order of each order, the denominator coefficient
FBLT (b, a, n, fl, fh, & amp; B [k * (n + 1) + 0], & amp; A [k * (n + 1) + 0]);//calculate the low-pass filter coefficients, and then into a bandpass coefficient
}
}
The static void BWTF (ln, l, n, k, d, c)
Int k, ln, n.
Double d [], [c];
{
int i;
Double PI, TMP;
PI=4.0 * atan (1.0);
D [0]=1.0;
C [0]=1.0;
for (i=1; i
D [I]=0.0;
[I] c=0.0;
}
TMP=(k + 1) - (ln + 1.0)/2.0;
If (TMP==0.0)
{
C [1]=1.0;
}
The else
{
C [1]=2.0 * cos (2 * (k + 1) + ln - 1) * PI/(2 * ln));
C [2]=1.0;
}
}
# include "stdlib. H"
The static void FBLT (d, c, n, FLN, FHN, b, a)
int n;
Double FLN, FHN, [d], c [], [] b, a, [].
{
Int I, k, m, n1, and n2, ls;
Double PI, w, w0, w1, w2, TMP, TMPD, TMPC, * the work;
Double combin ();
Void bilinear ();
PI=4.0 * atan (1.0);
W1=tan (PI * FLN);
For (I=n; I>=0; I -)
{
If (c [I]! [I]=0.0 | | (d!=0.0))
break;
}
M=I;//mark the location of the non-zero value
N2=2 * m;
N1=(n + 1;
The work=malloc (n1 n1 * * sizeof (double));
W2=tan (PI * FHN);
W=w2 - w1;
W0=w1 * w2;
for (i=0; i<=n2; I++)
{
The work [0 * n1 + I]=0.0;//1 carefully and l
The work [1 * n1 + I]=0.0;
}
for (i=0; i<=m; I++)
{
[I] * pow TMPD=d (w, (m - I));
[I] TMPD=c * pow (w, (m - I));
For (k=0; K<=I; K++)
{
Ls=m + I - 2 * k;
TMP=combin (I, I)/(combin (k, k) * combin (, I - I - k k));
The work [0 * n1 + ls] +=TMPD (w0, k) * * pow TMP;
The work [1 * n1 + ls] +=TMPC (w0, k) * * pow TMP;
}
}
for (i=0; i<=n2; I++)
{
[I]=d work [0 * n1 + I];
C=[I] the work [1 * n1 + I];
}
Free (work);
Bilinear (d, c, b, a, n);//consolidation coefficient of each level to a large collection of transfer function coefficients of
}
The static double combin (i1, i2)
Int i1, i2;
{
int i;
Double s;
S=1.0;
If (i2==0) return (s);
For (I=i1; I> (i1, i2); I -)
{
S *=I;
}
The return (s);
}
The static void bilinear (d, c, b, a, n)
int n;
Double d [], [c], [] b, a, [].
{
Int I, j, n1.
Double sum, atmp, scale, * temp;
N1=n + 1;
Temp=malloc (n1 n1 * * sizeof (double));
For (j=0; J<=n; J++)
{
\ [j * n1 + 0]=1.0;
}
Sum=1.0;
for (i=1; i<=n; I++)
{
Sum=sum * (double) (n - I - 1)/(double) I;
\ [0 * n1 + I]=sum;
}
for (i=1; i<=n; I++)
For (j=1; J<=n; J++)
{
\ [j * n1 + I]=temp [(j - 1) * n1 + I] - temp [j * n1 + I - 1] - temp [(j - 1) * n1 + I - 1].
}
For (I=n; I>=0; I -)
{
B [I]=0.0;
Atmp=0.0;
For (j=0; J<=n; J++)
{
[I] [I]=b + b temp n1 + I] [j * * d [j];
Atmp=atmp + temp n1 + I] [j * * c [j];
}
Scale=atmp;
If (I.=0)
{
A [I]=atmp;
}
}
for (i=0; i<=n; I++)
{
[I] [I]=b/b scale;
A [I]=[I] a/scale;
}
A [0]=1.0;
Free (temp);
}
This is iirbcf program
CodePudding user response:
# include & lt; Stdio. H># include "math. H"
Void gainc (b, a, n, ns, x, y, len, sign)
Int n, ns, len, sign;
Double [b], [a], [] x, y [];
{
Int I, j, k, n1;
Double ar, ai, br, bi, zr, zi, im, re, den, numr, numi, freq, temp.
Double hr, hi, tr, ti;
N1=n + 1;
For (k=0; K
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull