Get phase of a minimum phase IIR filter
q1=log_fir(t0,n1,file_a,tol)
The program calculates the phase of a minimum phase discrete IIR filter having specified gain. With piir() you can design a stable filter with arbitrary gain.
sample time
order of cosine series
an external file name. The file describes a gain spec.
allowable gain change. The value should be more than 0.
FIR type function.
The program calculates the phase of the function whoes gain is g1 at f1(Hz), g2 at f2(Hz),.. you create a file "file_a". In the file
f1 g1 p1
f2 g2 p2
..
q1c is defined as
q1c = a1+a2*cos(w1)+a3*cos(2*w1)+.
Then, the program selects a1,a2,.. so that
| log|gi| -q1c(fi) | is less than log(1+tol)
The phase is obtained from
exp(q1) = exp(a1+a2/z+a3/z^2+.)
The output q1 is
q1 = (a1+a2/z+a3/z^2+.)
The program uses LMI. If LMI stops, you may need to increase n1.
///// arbitrary function case z=%z; ts = 1; // sample time at = [ // gain spec 0.01,1 ,0; // gain is 1 at 0.01Hz 0.1,0.1 ,0; // 0.1 at 0.1 0.2,0.01 ,0; 0.3,0.1 ,0; 0.4,1 ,0; 0.49,1 ,0]; if MSDOS then unix('del foo'); else unix('rm -f foo'); end write('foo',at) q1=log_fir(ts,80,'foo',.03); px = piir(ts,12,'apgain.txt',0.1); // The order of px is 12. Phase error is 0.1 // px is the stable IIR filter having specified gain | ![]() | ![]() |