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
upfirdn, and even straight
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.
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;
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
s1 = resample(s0,p,q);
[p,q] = rat(resampleRate/sampleRate,1e-12);