MATLAB: How to re-sample a continuous function; but maintain shape

resamplesignal processingSignal Processing Toolbox

I am trying to resample a vector that represents a voltage time-series from 200kHz to 50 kHz using the resample function (the two vectors are shown below).
untitled.jpg
The code I've used to resample is as follows:
x = resample(x,5e4,20e4);
When I measure what we call the 'half width' (the duration of time at half the height of the voltage peak) I notice that there is an increase, essentially the half width becomes longer. The increase also varies between waveforms.
I am curious if there is anyway to reduce this discrepancy, or at least perhaps have it consistent and based on the slower sampling rate? I've tried using filter coefficients that mimick the shape of these waveforms; but that seemed to make things worse.
Thank you in advance!
Eric

Best Answer

I see several potential reasons why this is occuring.
1) There will be general broadening of the signal due to downsampling.
2) Since the magnitude of the downsampled signal is potentially lower, then half of the max could also be lower. So you could be measuring a wider part of the signal.
3) You're measuring half-width from the left side. This combined with issue 2 could lead to measuring something like the blue line in "Capture" (attachment). I would have defined the half-width as something more like the red line, which is the HWHM from the left side.
4) You're using discrete values to calculate width. Probably not an issue because the sampling rates are still quite high, but could lead to something occuring like in "Capture2" attachment. If you find this is a big issue, then you could interpolate between the first point <halfHeight and first point >halfHeight.
I'm not really sure what to suggest other than to try using the functions pulsewidth and/or statelevels in the signal processing toolbox.