this should be a fairly straightforward question since Mathematica has included functionality to filter data. Nevertheless, I am not being successful to solve the problem. Following the proposed solution here did not really help, since the syntax code is not working.
If you have 3 frequency data, you may make a lowpass filter and nicely filter out the low frequency data.
Generate data:
data1 = Table[{t,
3.23 Sin[2 \[Pi] 1.83 t] + 3.23 Sin[2 \[Pi] 5.33 t] +
3.23 Sin[2 \[Pi] 10.5 t]}, {t, 0, 100, 0.01}];
ListPlot[data1[[;; 1000 ;; 1]], PlotRange -> Automatic,
Joined -> True]
FFT of the data:
testdf1 = data1;
nn = Length@testdf1;(*Number of points*)
sr = 10^2.;(*Sample rate*)
freqs = Table[(n - 1) sr/nn, {n, nn}];
ft = Fourier[testdf1[[All, 2]], FourierParameters -> {-1, 1}]^1;
ListLogPlot[Transpose[{freqs, Abs[ft]}], PlotRange -> {{0, 15}, All},
Joined -> True]
Lowpass filter the data and compare it with initial data:
fn = data1[[All, 2]];
lowpass = ButterworthFilterModel[{10, 4. \[Pi] 2}];
filt1 = ToDiscreteTimeModel[lowpass, 1/sr];
fnfilt1 = RecurrenceFilter[filt1, fn];
ListPlot[{data1, Transpose[{data1[[All, 1]], fnfilt1}]},
Joined -> True, PlotRange -> {All, All}]
FFT of the filter data:
fnfiltft1 = Fourier[fnfilt1, FourierParameters -> {-1, 1}]^1;
ListLogPlot[Transpose[{freqs, Abs[fnfiltft1]}],
PlotRange -> {{0, 15}, All}, Joined -> True]
How do I do with similar procedure a highpass/bandpass filter ?
Everything I tried so far is not working reliably such as:
\[Omega]p = 10.; \[Omega]s = 20; ap = 20.; as = 2.;
tf = ButterworthFilterModel[{"Highpass", {\[Omega]p, \[Omega]s}, {ap,
as}}]
Thank you very much !
Comments
Post a Comment