I have an ECG signal having 500 Hz frequency and a signal having 257 HZ frequency. To process both signals i want both signals having frequency 300 Hz. So how to downsmaple the first ECG signal to 300 Hz and upsample the 2nd ECG signal to 300 Hz in python or MATLAB?
1 Answers
Matlab's signal processing toolbox has an upsample
command (link). Looking at it, it inserts zeros between values and I would guess it is intended for use with a low-pass filter. Similarly, Matlab's signal processing toolbox has a downsample
command that removes elements. link. Both of these only allow you to upsample/downsample by integer factors. These functions are probably not the way to go.
You could interpolate, using the interp1
function. An example is given here.
Instead of the above solutions, I would take a different approach. To upsample: FFT, zero-pad, and then IFFT. You can downsample a signal by using an FFT, getting rid of high-frequency components, and then using an IFFT. If you do this, then inspect the Fourier transform to make sure you are not getting rid of any useful information. If there is high-frequency information content, then you could consider upsampling both to 500Hz.

- 1,704
- 12
- 15
-
`interp1` is the way to go. Either the [MATLAB](https://www.mathworks.com/help/matlab/ref/interp1.html) version or the Python/NumPy/[SciPy](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html#scipy.interpolate.interp1d). Syntax for SciPy is a little wonky, but it gets the job done. – bfris Oct 11 '21 at 00:40