Question
I've been attempting to resample a GPS signal in MATLAB. I've built a few FIR filters using fvatool
and from handmade transfer functions (punched out with a HP-35s). Most are kaiser-windowed LPFs, but some are least-squared LPFs. All of the filters I've built have nominal responses that should adequately filter the aliasing out of the interpolations. I've also built a FFT-Resampling tool that resamples well and very quickly. However, I've hit a strange anomoly, at least as I see it. A simple 'nearest' neighbor interpolation using interp1
seems to much more accurately resample my signal than any FFT-Resampling I have done, or any upsample, filter, decimate tool I've used, to include dsp.FIRRateConverter
, resample
,upfirdn
, and even straight upsample
, filter
,decimate
. Why is this? Can anyone explain why this occurs? My theory is that when the rational integers of your sampling ratio are very close to one, straight interpolation will provide more accurate results because you reduce occilations and/or other noise distortion.
Background
My signal is a standard collected GPS signal, pulled from the air, sampled at 25e6 sps and saved in a binary file using signed 16-bit integers. When pulled into MATLAB (has to be done in chunks due to size) the signal is a complex row vector.
I'm upsampling to 26.25e6 sps, therefore my rational integers p and q are 21 and 20, respectively. To use interp1
I simply build two time vectors:
t0 = (0:1:numSamples - 1)*1/sampleRate;
t1 = (0:1:numResamples - 1)*1/resampleRate;
where
sampleRate= 25e6;
resampleRate = 26.25e6;
samplingRatio = resampleRate/sampleRate;
numSamples = length(s0) % length of my original signal, sampled at 25e6 samples
numResamples = length(s0)*samplingRatio % length of my sampled signal; should equal length(s1)
s1 = interp1(t0,s0,t1,'nearest','extrap');
When using a FIR filter, I have used many methods. But the simpliest is to call resample
like this (resample is a least squares FIR filter with a kaiser window called through firls
that gets pushed through upfirdn
):
s1 = resample(s0,p,q);
where
[p,q] = rat(resampleRate/sampleRate,1e-12);
interp1(x,Y,xi,'nearest')
giving a more accurate resample of your signal? Define "more accurate". Is it that the RMS difference with the known answer is better?nearest
chooses the nearest sample, so it will just give you 20 of your original samples and then the 21st will duplicate the 20th, and then repeat. I can't imagine how that could be more accurate than using linear interpolation. $\endgroup$s0
, and the resampled signal,s1
, is much closer when interpolated with'nearest'
than with filtered linear interpolation. For GPS, this is problematic, since the noise floor is so high. It could have something to do with the signal being complex? And your description of'nearest'
is off a little bit; it doesn't duplicate the 21st.'nearest'
takes the mean of the 20th and 21st original samples to produce the resampled 21st sample. $\endgroup$