Using the Lowpass filter to properly filter data without a time variable
17 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ash21
am 14 Jul. 2021
Kommentiert: Star Strider
am 15 Jul. 2021
Hello,
I am having some issues getting the Lowpass filter to work on my data. I have an x and y variable where x is the inputs and y is the outputs, but they are not related by a function and I am not interesed in plotting time, which I know is generally used with the Lowpass filter. I have tried many different variations of code for the Lowpass and have gotten graphs that appear to be working but when I go to lower the frequency to get rid of the noise, nothing happens. Meaning my graph with a cutoff frequency of 1 looks the same as my graph with a cutoff frequency of 0.001. Is anyone able to explain why this might be or how I might fix it? As the graph still looks farily noisy and I would like it to be a smoother curve. For reference my Fs value is 12, x and y are two fairly long columns of data, and the FilterOrder I have changed around a lot but it doesn't seem to change my plot.
Fs=12;
d=designfilt('lowpassfir','FilterOrder',5,'cutoffFrequency',0.01,'SampleRate',Fs)
k=filter(d,x);
p=filer(d,y);
plot(k,p)
I have also tried some options where the the cutoff frequency does seem to change above 1, so this is not the most helpful to me. It will also not let me plot my two variables, it seems to only want to use time/Hertz. Maybe this is my main issue? I tried what is below as well for this but it does not seem to be doing what I want it to. I also tried incorportating a smoothingspline to help relate the varibales but this does not really seem to be working (although this code did not give me an error message).
Any help would be appreciated!
f=fit(x,y,'smoothingspline');
plot(f,x,y,'b')
Fs=12;
k=f(x);
p=lowpass(k,0.01,fs);
plot(x,p,'r')
0 Kommentare
Akzeptierte Antwort
Star Strider
am 14 Jul. 2021
It is always best to use the freqz function to see what the filter is actually doing. (I find fvtool a bit difficult to work with.)
Fs=12;
d=designfilt('lowpassfir','FilterOrder',5,'cutoffFrequency',0.01,'SampleRate',Fs)
figure
freqz(d.Coefficients, 1, 2^14, Fs)
Experiment to see if increasing the order of the filter improves its performance:
Fs=12;
d=designfilt('lowpassfir','FilterOrder',45,'cutoffFrequency',0.01,'SampleRate',Fs)
figure
freqz(d.Coefficients, 1, 2^14, Fs)
.
6 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

