Added improved downsampling. Need to finish : downsample after filter.
This commit is contained in:
parent
b2224152f4
commit
5b792182c6
|
|
@ -0,0 +1,37 @@
|
||||||
|
function [Z, P]= iirFilter(N, cutoffFreq, samplingFreq, filterType)
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
% function [Z, P] = iirFilter(N, cutoffFreq, samplingFreq, filterType)
|
||||||
|
% ex.: [Z, P] =iirFilter(6, 10, 500, 1)
|
||||||
|
%
|
||||||
|
% Task: To create and analyze an IIR low pass filter (Butterworth ror Chebychev)
|
||||||
|
%
|
||||||
|
% Inputs:
|
||||||
|
% -N: order of the filter
|
||||||
|
% -cutoffFreq: below this frequency, signal is not modified and above signal is attenuated
|
||||||
|
% -samplingFreq: sampling frequency (In Hz)
|
||||||
|
% -filterType: Butterworth if equal to 1 and Chebychev if equal to 2
|
||||||
|
%
|
||||||
|
% Outputs:
|
||||||
|
%
|
||||||
|
%
|
||||||
|
% Author: Guillaume Gibert, guillaume.gibert@ecam.fr
|
||||||
|
% Date: 09/04/2025
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
if (filterType == 1)
|
||||||
|
[b, a] = butter(N, cutoffFreq/(samplingFreq/2));
|
||||||
|
elseif (filterType == 2)
|
||||||
|
Rp = 10; % bandpass ripple of Rp dB
|
||||||
|
[b, a] = cheby1(N, Rp, cutoffFreq/(samplingFreq/2));
|
||||||
|
else
|
||||||
|
disp('Filter type is incorrect!')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
[Z, P] = zeroPole(a, b, 1);
|
||||||
|
|
||||||
|
figure;
|
||||||
|
freqz(b, a, N, samplingFreq);
|
||||||
|
title('Frequency response');
|
||||||
|
grid on;
|
||||||
|
|
||||||
Loading…
Reference in New Issue