If you want to design filters with matlab, you can start by reading about them in the documentation, for instance here. If you want to just wing it then you can study the effects of different parameters using the fvtool
utility. Like most tools, however, you are more likely to get something out of it if you spend a few minutes reading the user's manual. For starters you will want to have some idea of where to set a frequency cutoff.
The following figure shows the frequency response of 3 different filters. The left panel is the response of your filter and highlights why you observed an amplification: low frequency signals are scaled by a factor of ~10. The filter you used is type IIR with feedback. The middle panel shows a similar filter with a more reasonable choice of b
. A simpler FIR filter that might suit your needs, shown on the right, was generated with fir1
. The drawback with the IIR filter is that it does not exhibit a uniform group delay response for all frequencies, which for your particular application is probably undesirable.
The following figure shows the raw and filtered data obtained with an IIR and FIR filters:
Finally, the following shows your data in the frequency domain before and after filtration. The drop in signal above 2.5 Hz due to the filters is evident. The response to the selected FIR filter is not as smooth as for the IIR filter and gives rise to ripples, but has a more abrupt dropoff, attenuating high frequency signals more than those at lower frequency.