Code Examples (Advanced DSP)

Matlab file for the comparison of window sequences

%**************************************************************************
% Comparison of "standard" and a bit more "advanced" window functions
%**************************************************************************

%**************************************************************************
% Basis parameters
%**************************************************************************
N_win =   64;
N_dft = 1024*16;

%**************************************************************************
% Basic windows - rectangle window
%**************************************************************************
h_rec     = ones(N_win,1);
h_rec     = h_rec / sum(h_rec);

H_rec     = fft(h_rec,N_dft);
H_rec     = H_rec(1:N_dft/2+1);
H_rec_log = 20*log10(abs(H_rec)+eps);

%**************************************************************************
% Basic windows - Hann window
%**************************************************************************
h_han     = hann(N_win);
h_han     = h_han / sum(h_han);

H_han     = fft(h_han,N_dft);
H_han     = H_han(1:N_dft/2+1);
H_han_log = 20*log10(abs(H_han)+eps);

%**************************************************************************
% Basic windows - Hamming window
%**************************************************************************
h_ham     = hamming(N_win);
h_ham     = h_ham / sum(h_ham);

H_ham     = fft(h_ham,N_dft);
H_ham     = H_ham(1:N_dft/2+1);
H_ham_log = 20*log10(abs(H_ham)+eps);

%**************************************************************************
% Advanced windows - "Chebyshev" window
%**************************************************************************
h_che     = chebwin(N_win,10);
h_che     = h_che / sum(h_che);

H_che     = fft(h_che,N_dft);
H_che     = H_che(1:N_dft/2+1);
H_che_log = 20*log10(abs(H_che)+eps);

%**************************************************************************
% Advanced windows - "Prolate" window
%**************************************************************************
h_pro     = dpss(N_win,1.18);
h_pro     = h_pro / sum(h_pro);

H_pro     = fft(h_pro,N_dft);
H_pro     = H_pro(1:N_dft/2+1);
H_pro_log = 20*log10(abs(H_pro)+eps);

%**************************************************************************
% Show results
%**************************************************************************
fig = figure(1);
f = (0:N_dft/2)/N_dft*2;

plot(f,H_rec_log,'b', ...
     f,H_han_log,'r', ...
     f,H_ham_log,'k', ...
     f,H_che_log,'m', ...
     f,H_pro_log,'c', ...
     'LineWidth',2);
legend('Rectangle window', ...
       'Hann window', ...
       'Hamming window', ...
       'Chebyshev window', ...
       'Prolate spheroidal window')
grid on;
xlabel('Normalized frequency $\Omega/\pi$','interpreter','latex');
ylabel('dB')
ylim([-90 10])

 

Matlab file for the effects of quantization on filter design

%**************************************************************************
% Design parameters
%**************************************************************************
N   =  8;     % Filter order
f_c =  0.1;   % Normalized cut-off frequency (0 ... 1)
R_p =  0.5;   % Ripple in dB in passband
R_s = 80;     % Stopband attenuation in dB

%**************************************************************************
% Design of an elliptic lowpass filter
%**************************************************************************
[b,a] = ellip(N, R_p, R_s, f_c);

%**************************************************************************
% Show frequency response
%**************************************************************************
fig = figure(1);
set(fig,'Units','Normalized');
set(fig,'Position',[0.1 0.1 0.8 0.8]);
[H,Omega] = freqz(b,a,2048*4,'whole',2);
plot(Omega,20*log10(abs(H)+eps),'b','LineWidth',2);
grid on
axis([0 2 (-R_s -20) 20])
xlabel('Normalized frequency \Omega/\pi')
ylabel('dB')


%**************************************************************************
% Quantization
%**************************************************************************
B = 32; % Number of bits

a_max = max(abs(a));
b_max = max(abs(b));

a_q = round(a / a_max * 2^B) / 2^B * a_max;
b_q = round(b / b_max * 2^B) / 2^B * b_max;

%**************************************************************************
% Show frequency response of quantized filter
%**************************************************************************
[H_q,Omega] = freqz(b_q,a_q,2048*4,'whole',2);
hold on;
plot(Omega,20*log10(abs(H_q)+eps),'r','LineWidth',2);
hold off;
legend('Non-quantized',['Quantized with ',num2str(B),' bits'])

%**************************************************************************
% Show coefficients
%**************************************************************************
format long;
a
a_q
b
b_q

%**************************************************************************
% Transform to cascade of biquad filters
%**************************************************************************
[sos,g] = tf2sos(b,a);

[L,L_tmp] = size(sos);

sos_q = round(sos / max(max(abs(sos))) * 2^B) / 2^B * max(max(abs(sos)));
g_q   = round(g^(1/L) * 2^B) / 2^B;

H_bq_q = freqz(g_q*sos_q(1,1:3),sos_q(1,4:6),2048*4,'whole',2);
for k = 2:L
    H_bq_q = H_bq_q .* freqz(g_q*sos_q(k,1:3),sos_q(k,4:6),2048*4,'whole',2);
end;

%**************************************************************************
% Show frequency response of quantized biquad filters
%**************************************************************************
[H_q,Omega] = freqz(b_q,a_q,2048*4,'whole',2);
hold on;
plot(Omega,20*log10(abs(H_bq_q)+eps),'k','LineWidth',2);
hold off;
legend('Non-quantized',['Quantized with ',num2str(B),' bits'],...
       'Biquad structure (also qunatized)');

 

Recent Publications

P. Durdaut, J. Reermann, S. Zabel, Ch. Kirchhof, E. Quandt, F. Faupel, G. Schmidt, R. Knöchel, and M. Höft: Modeling and Analysis of Noise Sources for Thin-Film Magnetoelectric Sensors Based on the Delta-E Effect, IEEE Transactions on Instrumentation and Measurement, published online, 2017

P. Durdaut, S. Salzer, J. Reermann, V. Röbisch, J. McCord, D. Meyners, E. Quandt, G. Schmidt, R. Knöchel, and M. Höft: Improved Magnetic Frequency Conversion Approach for Magnetoelectric Sensors, IEEE Sensors Letters, published online, 2017

 

Website News

18.06.2017: Page about KiRAT news added (also visible in KiRAT).

31.05.2017: Some pictures added.

23.04.2017: Time line for the lecture "Adaptive Filters" added.

13.04.2017: List of PhD theses added.

Contact

Prof. Dr.-Ing. Gerhard Schmidt

E-Mail: gus@tf.uni-kiel.de

Christian-Albrechts-Universität zu Kiel
Faculty of Engineering
Institute for Electrical Engineering and Information Engineering
Digital Signal Processing and System Theory

Kaiserstr. 2
24143 Kiel, Germany

Recent News

Alexej Namenas - A New Guy in the Team

In June Alexej Namenas started in the DSS Team. He will work on real-time tracking algorithms for SONAR applications. Alexej has done both theses (Bachelor and Master) with us. The Bachelor thesis in audio processing (beamforming) and the Master thesis in the medical field (real-time electro- and magnetocardiography). In addition, he has intership erperience in SONAR processing.

We are pretty ...


Read more ...