kopia lustrzana https://github.com/Dsplib/libdspl-2.0
Changes to be committed:
modified: dspl/dox/en/filter_ap.dox modified: dspl/dox/ru/filter_ap.dox modified: examples/src/butter_ap_zp_test.cpull/6/merge
rodzic
2962244fcc
commit
a557330fe6
|
@ -52,11 +52,10 @@ Example:
|
|||
Result:
|
||||
|
||||
\verbatim
|
||||
b[ 0] = 1.002 a[ 0] = 1.002
|
||||
b[ 1] = 0.000 a[ 1] = 2.618
|
||||
b[ 2] = 0.000 a[ 2] = 3.418
|
||||
b[ 3] = 0.000 a[ 3] = 2.615
|
||||
b[ 4] = 0.000 a[ 4] = 1.000
|
||||
b[ 0] = 1.965 a[ 0] = 1.965
|
||||
b[ 1] = 0.000 a[ 1] = 3.138
|
||||
b[ 2] = 0.000 a[ 2] = 2.505
|
||||
b[ 3] = 0.000 a[ 3] = 1.000
|
||||
\endverbatim
|
||||
\n
|
||||
|
||||
|
@ -140,6 +139,31 @@ Else \ref ERROR_CODE_GROUP "code error".
|
|||
Normalized Butterworth lowpass filter has no finite zeros.
|
||||
So `z` vector will not changed and in pointer `nz` will write 0 value. \n
|
||||
|
||||
Example of normalized Butterworth lowpass filter zeros and poles calculation:
|
||||
\include butter_ap_zp_test.c
|
||||
|
||||
Result:
|
||||
|
||||
\verbatim
|
||||
Butterworth filter zeros: 0
|
||||
Butterworth filter poles: 7
|
||||
p[ 0] = -1.101 +0.000 j
|
||||
p[ 1] = -0.245 +1.074 j
|
||||
p[ 2] = -0.245 -1.074 j
|
||||
p[ 3] = -0.687 +0.861 j
|
||||
p[ 4] = -0.687 -0.861 j
|
||||
p[ 5] = -0.992 +0.478 j
|
||||
p[ 6] = -0.992 -0.478 j
|
||||
\endverbatim
|
||||
\n
|
||||
|
||||
In `dat` folder will be created `butter_ap_zp.txt` file. \n
|
||||
|
||||
In addition, GNUPLOT will build the following graphs
|
||||
from data stored in `dat/butter_ap_zp.txt` file:
|
||||
|
||||
\image html butter_ap_zp_test.png
|
||||
|
||||
\author Sergey Bakhurin www.dsplib.org
|
||||
***************************************************************************** */
|
||||
|
||||
|
|
|
@ -150,6 +150,32 @@ www.dsplib.org
|
|||
Нормированный ФНЧ Баттерворта не имеет нулей, поэтому массив нулей `z`
|
||||
не будет изменен, а по указателю `nz` будет записан 0. \n
|
||||
|
||||
|
||||
Пример программы рассчета нулей и полюсов нормированного ФНЧ Баттерворта:
|
||||
\include butter_ap_zp_test.c
|
||||
|
||||
Результат выполнения программы:
|
||||
|
||||
\verbatim
|
||||
Butterworth filter zeros: 0
|
||||
Butterworth filter poles: 7
|
||||
p[ 0] = -1.101 +0.000 j
|
||||
p[ 1] = -0.245 +1.074 j
|
||||
p[ 2] = -0.245 -1.074 j
|
||||
p[ 3] = -0.687 +0.861 j
|
||||
p[ 4] = -0.687 -0.861 j
|
||||
p[ 5] = -0.992 +0.478 j
|
||||
p[ 6] = -0.992 -0.478 j
|
||||
\endverbatim
|
||||
\n
|
||||
|
||||
В каталоге `dat` будет создан файл `butter_ap_zp.txt`. \n
|
||||
|
||||
Пакет GNUPLOT произведет построение карты полюсов по
|
||||
сохранненным в `dat/butter_ap_zp.txt` данным:
|
||||
|
||||
\image html butter_ap_zp_test.png
|
||||
|
||||
\author
|
||||
Бахурин Сергей
|
||||
www.dsplib.org
|
||||
|
|
|
@ -16,19 +16,22 @@ int main(int argc, char* argv[])
|
|||
|
||||
complex_t z[ORD+1]; /* H(s) zeros vector */
|
||||
complex_t p[ORD+1]; /* H(s) poles vector */
|
||||
double Rp = 1.0; /* Magnitude ripple from 0 to 1 rad/s */
|
||||
double Rp = 1.0; /* Magnitude ripple from 0 to 1 rad/s */
|
||||
|
||||
int res, k, nz, np;
|
||||
|
||||
|
||||
/* Zeros and poles vectors calculation */
|
||||
res = butter_ap_zp(ORD, Rp, z, &nz, p, &np);
|
||||
if(res != RES_OK)
|
||||
printf("error code = 0x%8x\n", res);
|
||||
|
||||
/* print H(s) zeros values */
|
||||
printf("Butterworth filter zeros: %d\n", nz);
|
||||
for(k = 0; k < nz; k++)
|
||||
printf("z[%2d] = %9.3f %+9.3f j\n", k, RE(z[k]), IM(p[k]));
|
||||
|
||||
/* print H(s) poles values */
|
||||
printf("Butterworth filter poles: %d\n", np);
|
||||
/* Print H(s) coefficients */
|
||||
for(k = 0; k < np; k++)
|
||||
printf("p[%2d] = %9.3f %+9.3f j\n", k, RE(p[k]), IM(p[k]));
|
||||
|
||||
|
@ -38,7 +41,8 @@ int main(int argc, char* argv[])
|
|||
/* plotting by GNUPLOT */
|
||||
gnuplot_create(argc, argv, 440, 360, "img/butter_ap_zp_test.png", &hplot);
|
||||
gnuplot_cmd(hplot, "unset key");
|
||||
gnuplot_cmd(hplot, "set grid");
|
||||
gnuplot_cmd(hplot, "set xzeroaxis");
|
||||
gnuplot_cmd(hplot, "set yzeroaxis");
|
||||
gnuplot_cmd(hplot, "set xlabel 'sigma'");
|
||||
gnuplot_cmd(hplot, "set ylabel 'jw'");
|
||||
gnuplot_cmd(hplot, "set size square");
|
||||
|
|
Ładowanie…
Reference in New Issue