git-svn-id: http://moon:8086/svn/matlab/trunk@153 801c6759-fa7c-4059-a304-17956f83a07c
31 lines
408 B
Matlab
Executable File
31 lines
408 B
Matlab
Executable File
function [y, gain] = cic_filter(R, M, N, x)
|
|
% [y, gain] = cic_filter(R, M, N, x)
|
|
|
|
a_i = [1 -1];
|
|
b_i = 1;
|
|
|
|
a_c = 1;
|
|
b_c = [1 zeros(1, M-1) -1];
|
|
|
|
gain = (M*R)^N
|
|
k_i = 1/(M*R);
|
|
|
|
i_out = x;
|
|
|
|
% Integrator
|
|
for i=1:N,
|
|
i_out = k_i*filter(b_i, a_i, i_out);
|
|
end;
|
|
|
|
% Decimate
|
|
c_out = i_out(R:R:length(i_out));
|
|
|
|
% Comb
|
|
for i=1:N,
|
|
c_out = filter(b_c, a_c, c_out);
|
|
end;
|
|
|
|
|
|
y = c_out;
|
|
|