Hello!
To get the cutoff frequency when using lowpass() function, I used powerbw(x,Fs) function.
Is this correct?
Thanks

 Akzeptierte Antwort

Star Strider
Star Strider am 11 Mai 2020

0 Stimmen

Is this correct?
That depends on the signal, and on what you want to do. The powerbw funciton returns the -3 dB frequencies if you request them (see: Bandwidth of Bandlimited Signals). For a lowpass filter, you would likely use the fhi output, if the intent is to use that part of the spectrum, or flo to exclude it.
It is probably as good a method as any of choosing a frequency for a filter. (I characteristically calculate the fft of the signal and then use it to design the filter, however there a definitely other ways.)

10 Kommentare

Dhanushka Palipana
Dhanushka Palipana am 11 Mai 2020
Below is part of the signal that should be fitered. lowpass output signal seems good in other parts of the signal, but I'm a bit worried about how lowpass() filter works at these peaks.
  1. I tried using 0.99 power point as the cutoff frequency too. But this doesn't make any good significant difference to the output signal.
  2. filtfilt gives results almost like lowpass (for filtfilt, b=0.2 was used here, using trial and error)
  3. filter gives an output signal which is still a bit noisy.(for filter, b=0.2 was used here, using trial and error)
Any recommendations on which signal is suitable?(Like, which is with lesser noise but still a good representation of the data)
Any recommendations on any other ways I can make the lowpass output signal better(by changing cutoff frequency, maybe?)
Thank you!!!
I get the impression that ‘filtfilt’ was a simple FIR filter, however it would be nice to know for sure.
The signal has a sharp transition (step discontinuity) at about 12400. All filters are going to have problems with abrupt transitions. This (and the accompanied ‘ringing’ is known as the Gibbs phenomenon and is a well-known problem in signal processing (continuous and discrete). One way of dealing with that is to use a longer (higher-order) filter, however that has its obvious limitations.
I cannot see the lower limit of that discontinuity, however the magnitude of the ‘ringing’ that is visible does not appear to be significantly different from the magnitude of the other signal characteristics. It is likel;y best to simply ignore it. However if the discontinuity itself is a problem, dealing with it depends on what you want to do with the data. Thresholding it and interpolating over it is one possibility, using a sufficiently restrictive lowpass filter to eliminate it is another. The best way to analyse it would be to do a fft on it and then design a filter to eliminate the undesirable frequencies.
Example Fourier Transform code —
t = linspace(0, 5, 1000); % Create Time Vector
s = sum(sin([1; 15; 30]*2*pi*t)); % Create Signal
Ts = t(2); % Sampling Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t);
n = 2*nextpow2(numel(s));
FTs = fft(s-mean(s), 2^n)/L;
Fv = linspace(0, 1, fix(2^n/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTs(Iv)))
grid
.
Dhanushka Palipana
Dhanushka Palipana am 11 Mai 2020
Sorry! I don't know how to recognize difference between FIR and other filters.
How do we select the cutoff frequency by looking at fft plot?
Star Strider
Star Strider am 11 Mai 2020
No worries!
FIR filters are finite-impulse response filters. In transfer function representation, ‘b’ is a vector (usually summing to 1) and ‘a’ is 1.
The fft plot will show the frequency content of the signal. Use that information to decide what frequencies to retain and what frequencies to reject. Then, design the filter appropriately.
Dhanushka Palipana
Dhanushka Palipana am 11 Mai 2020
Thank you very much!! :D
Star Strider
Star Strider am 11 Mai 2020
As always, my pleasure!
Dhanushka Palipana
Dhanushka Palipana am 12 Mai 2020
Hello again,
If the filtfilt filter I have used is a FIR filter, does it need any modifications/aterations to match with the original filter or what I have already done is fine?
Thanks
As always, my pleasure!
If it gives you the result you want, then leave it alone. If it does not, you may need to re-design it.
I get the impression that ‘filtfilt’ is something like this:
y_filt = filtfilt(0.2, 1, y);
however I do not know for certain.
I might mention here that if you have a variable or function named ‘filtfilt’, it is best to re-name it to something else. Naming variables or other functions the same as MATLAB built-in functions is called ‘overshadowing’ and is to be absolutely avoided.
Dhanushka Palipana
Dhanushka Palipana am 12 Mai 2020
This is not a designed function. I used the matlab in-build function filtfilt. And those are exactly what I used for b and a(They are just trial and error). The output signal seems to be similar as the output signal from lowpass filter. So, I feel like the output is ok. I was worried if there can be any changes to the signal that is unrecognizable by just looking at the output signal plot. (Also, like those weird things happening near the peaks).
Thank you!!
Star Strider
Star Strider am 12 Mai 2020
As always, my pleasure!
No worries — I just want to be sure that you are not overshadowing filtfilt.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by