The Journey to Digital Filter Design: Band-pass Filter

1 Basic princeples To design a Butterworth band-pass filter, we can combine a low-pass filter and a high-pass filter as below, $$ H(z) = H_{lp}(z) \cdot H_{hp}(z) \tag{1}. $$ In previous blogs, we’ve gone over the Butterworth low-pass and high-pass filters. Here, we use the designed filters to construct a band-pass filter. You can also design a Butterworth band-stop filter according to the designed low-pass and high-pass filters if necessary. $$ \begin{cases} H_{lp}(z) &= H_{\omega_2}(z)\\

The Journey to Digital Filter Design: High-pass Filter

1 Basic princeples For a Butterworth high-pass filter, the squared frequency response is given by $$ |H(\omega)|^2 = \frac{1}{1+(\frac{tan\frac{\omega_c}{2}}{\frac{\omega}{2}})^{2N}} \tag{1}. $$ Using $tan\frac{\omega}{2}=\frac{1}{j}\frac{1-e^{-j\omega}}{1+e^{-j\omega}}$ and $z=e^{-j\omega}$, we have $$ |H(z)|^2=\frac{(-1)^N(\frac{1-z^{-1}}{1+z^{-1}})^{2N}}{(-1)^N(\frac{1-z^{-1}}{1+z^{-1}})^{2N}+tan^{2N}\frac{\omega_c}{2}} \tag{2}. $$ We know there $N$ repeated zeros $1$ of this transfer function, and the poles are little bit complicated. We first calculate $q_k=\frac{1-z_k^{-1}}{1+z^{-1}}$. $$ q_k= \begin{cases} &tan\frac{\omega_c}{2}e^{j\frac{2k+1}{2N}\pi}, \text{ for } N \text{ is even and }k=0, 1, 2, \cdots, 2N-1;\\

Error Bars in GMT

1 2 3 4 5 6 7 8 9 10 11 12 13 14 R=0/10/0/100 J=X5i/5i PS=error-bar-gmt.ps PDF=error-bar-gmt.pdf awk 'BEGIN{for(i=2;i<10;i++){print i,i*i}}' > tmp.lst psxy -R$R -J$J -K -T > $PS psxy tmp.lst -R -J -K -O -B1:"X-axis":/10:"Y-axis":WSen -W1p,"--" >> $PS awk '{print $1,$2,3.5,1}' tmp.lst | psxy -R -J -K -O -Ey/3p >> $PS psxy tmp.lst -R -J -K -O -Si0.5c -Gblack >> $PS psxy -R -J -O -T>> $PS ps2pdf $PS $PDF

Print Colorful Strings in C

It’s wonderful to print colorful strings on your terminal and here we show you how to do that. 1 2 3 4 5 6 7 8 9 10 11 #include <stdio.h> int main() { char ss[1024] = {"Colorful!!!"}; printf("\033[0;31m %s \033[0;39m\n", ss); // red printf("\033[0;32m %s \033[0;39m\n", ss); // green printf("\033[0;33m %s \033[0;39m\n", ss); // yellow printf("\033[0;34m %s \033[0;39m\n", ss); // blue printf("\033[0;35m %s \033[0;39m\n", ss); // purple return 0; }

Function Pointer & Pointer Function

1 Ponter function Function pointer is a pointer in c, and it returns a pointer of some type. For instance, its declaration follows 1 2 int *f(int x, int y); Let’s give a code demo to show function pointer. 1 2 3 4 5 6 7 8 9 10 11 12 13 int *add2Num() { int x = 10, y = 20; static int out[3] = {0}; out[0] = 10; out[1] = y; out[2] = x + y; return out; } int main() { int *p = NULL; p = add2Num(); printf("%d\n", *(p+1)); return 0; } Output 20