Why do I get different results for mkfilter and butter?

1 view (last 30 days)
I would like to apply low pass filters (different cutoff frequencies) on multiple time series of existing data. In the next step, I would like to use these time series to investigate whether the lack of certain frequencies has a noticeable effect on a system I investigate. However, my experience with filtering is rudimental. Since I am really interested in preserving the signal in the non-filtered range it seems as a low order Butterworth filter would suit my needs (constant magnitude, low phase shift). As far as I understand I can as well choose a higher order filter for a sharper cutoff but this increases the phase shift and therefore modifies my signal?
To understand how to prepare such a Butterworth filters in matlab I used two different approaches based on the functions mkfilter and butter. I was expecting to get identical results but this is not the case. What am I missing? In the butter approach I can observe a very steep drop at approximately 25Hz. Is is in line with expectations? I am using matlab 2017a on a Ubuntu 17.10 system.
fc = 1;
dt = 0.02;
t = 1:dt:1000;
signal_01 = 10 + sin(t*0.2) + sin(t*0.4) + sin(t*4);
% mkfilter approach
G_s = mkfilter(fc, 2, 'butterw');
figure(1)
h = bodeplot(G_s)
setoptions(h,'FreqUnits','Hz','PhaseVisible','on','PhaseMatching','on','Grid', 'on');
% butter approach
Wn = fc/((1/dt)/2);
[b,a] = butter(2, Wn, 'low');
figure(2)
h = bodeplot(tf(b, a, dt))
setoptions(h,'FreqUnits','Hz','PhaseVisible','on','PhaseMatching','on','Grid', 'on');

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!