m = 2;  % Differential delays in the filter.
n = 4;  % Filter sections
r = 1;   % Decimation factor
x = int16(zeros(160,1)); x(1) = 1;    % Create a 160-point
                                      % impulse signal.
hm = mfilt.cicdecim(r,m,n); % Expects 16-bit input
                            % by default.
y = filter(hm,x);
yCorr = double(y);

% stem(yCorr);    % Plot output as a stem plot.
% xlabel('Samples'); ylabel('Amplitude');
% title('Decimated Signal');

FilteredDataFft = abs(fft(yCorr));
FilteredDataFftDb = 20*log10(FilteredDataFft);
FilteredDataFftDb = FilteredDataFftDb-max(FilteredDataFftDb);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure('name','In Data Time/Freq', 'Numbertitle', 'off')
subplot(3,1,1)
plot(x)
grid on;
grid minor;
title('In Signal')
xlabel('Time')
ylabel('Amp')

subplot(3,1,2)
plot(yCorr)
grid on;
grid minor;
title('Imp Resp')
xlabel('Time')
ylabel('Amp')

subplot(3,1,3)
plot(FilteredDataFftDb)
grid on;
grid minor;
title('Filtered Data')
xlabel('Time')
ylabel('Amp')