MATLAB: How to design a lowpass filter for ocean wave data in Matlab

bandpassfilterjulian dataMATLABoceanographywaves

Hi there.
What frequency specification should I use in order to create a low-pass filter ? ( Specifically filter order and Frequency specifications) I have a huge data set contains unfiltered water level data and it is in meters relative to mean lower water (MLW) at hourly intervals. The time stamp is in Julian data.
thank you in advance.

Best Answer

You need to know the passband of the filter you want to design (the frequencies you want to either keep or filter out), and the sampling frequency (Fs) at the very least. Since you have Fs, the Signal Processing Toolbox makes the rest easy. From your description, a Butterworth design is likely the best. You are always free to experiment with other designs, but the scheme I’m outlining for the Butterworth design is a prototype for all of them. You have already decided on a lowpass design, the default for all of them, so you don’t have to specify a filter type. (I usually prefer a bandpass with a very low cutoff, in the event that I want to filter out baseline drift. That’s simply my personal bias, because my signals usually have baseline drift.)
  1. To determine the order, start with the buttord function;
  2. Use the output of buttord to design a transfer function (b,a) realization of your filter with the butter function, (I usually use 1 dB for Rp and 10 dB for Rs, but these are not relevant for Butterworth designs);
  3. Use the tf2sos function to create a second-order-section representation for stability;
  4. Use the trapz function (be sure to give it your sampling frequency, ‘Fs’, to make the output understandable) in order to check the filter performance to be sure it is stable and does what you intend it to do;
  5. Use the filtfilt function for the actual filtering, since unlike filter, filtfilt does not introduce any phase distortion.
The documentation is reasonably clear on all these, so their usage should be straightforward, but that assumes some experience in discrete signal processing. If you have any problems, follow up here and I’ll do my best to help you solve them.