Resampling a binary data

22 views (last 30 days)
Bugrahan Ustundag
Bugrahan Ustundag on 27 Aug 2022
Commented: Image Analyst on 4 Sep 2022
TEXBAT is a recorded dataset about spoofing scenarios for evaluating GPS signal authentication techniques.
On this project, there are recorded GPS signals stored as complex 16- bit samples at a rate of 25 Msps.
I want to change its sample rate because maximum sample rate of my SDR (RTL-SDR) is 3.2Msps.
How can I change its sample rate from 25Msps to sample rates below than 3.2Msps?
  3 Comments
Bugrahan Ustundag
Bugrahan Ustundag on 27 Aug 2022
Edited: Bugrahan Ustundag on 27 Aug 2022
Thanks @Star Strider for the suggestion, to be more clear,
The data file is a binary file comprising of I and Q of the sampled signal. They are complex sampled. For more info: I/Q files (.bin files)
I want to resample a .bin file and create a new-sampled .bin file.
Is
resample
function valid for complex sampled signals too?
Walter Roberson
Walter Roberson on 27 Aug 2022
I don't think I quite understand some of these outputs
data = repelem([1+2i, -3-4i], 1, 4).'
data =
1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i -3.0000 - 4.0000i -3.0000 - 4.0000i -3.0000 - 4.0000i -3.0000 - 4.0000i
resample(data, 1, 2)
ans =
0.6532 + 1.3483i 1.2706 + 2.4499i -1.9323 - 2.4326i -3.4466 - 4.6259i
ifft(fft(data), 4)
ans =
4.2426 - 1.8284i -0.0000 + 1.0000i -8.2426 - 2.1716i -4.0000 - 5.0000i
interp1(1:length(data), data, 1:2:length(data)).'
ans =
1.0000 + 2.0000i 1.0000 + 2.0000i -3.0000 - 4.0000i -3.0000 - 4.0000i
data = repelem([1+2i], 1, 8).'
data =
1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i
resample(data, 1, 2)
ans =
0.7370 + 1.4740i 1.0880 + 2.1760i 0.9318 + 1.8636i 1.0880 + 2.1760i
ifft(fft(data), 4)
ans =
2.0000 + 4.0000i 2.0000 + 4.0000i 2.0000 + 4.0000i 2.0000 + 4.0000i
interp1(1:length(data), data, 1:2:length(data)).'
ans =
1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i 1.0000 + 2.0000i
I guess the fft result suggests that the power is being redistributed over the output, so the ifft output should probably be divided by the decimination factor

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 27 Aug 2022
The input vector has to be a real double array. So resample the real and imaginary parts separately.
Doing the experiment —
Fs = 1000;
t = linspace(0, 9999, 10000).'/Fs; % Assume Column Vectors
sz = exp(2*pi*1i*t*100);
% Resz = real(sz);
% Imsz = imag(sz);
[zrr,tr] = resample(real(sz),t,500);
[zir,tr] = resample(imag(sz),t,500);
szr = zrr + 1i*zir;
figure
plot(t, real(sz), '.-', t, imag(sz),'.-', 'DisplayName','Original (Fs = 1000)')
hold on
plot(tr, real(szr), 's-', tr, imag(szr), 's-', 'DisplayName','Resampled (Fs = 500)')
hold off
grid
legend('Location','best')
xlim([0 1]*5E-2)
It appears to work as expected.
.
  2 Comments
Bugrahan Ustundag
Bugrahan Ustundag on 4 Sep 2022
should I apply a FIR filter before the sampling?
Star Strider
Star Strider on 4 Sep 2022
I am not certain what you are referring to.
If you are sampling an analog signal, it is appropriate to do analog filtering of the signal prior to digitising it using a Bessel lowpass filter with the cutoff frequency slightly less than the sampling frequency of the A/D converter. Bessel filters are characteristically IIR filters, and are preferred here because they do not exhibit any phase distortion in the passband.
I generally prefer IIR filters unless I need them to have several different passbands or stopbands in the filter. In that situation, FIR filters are generally easier to design and implement, and I usually use them only as discrete filters with a signal that has already been digitised

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 27 Aug 2022
If you can read it into a time, t, array and gps (y) array, you might try interp1
gpsNew = interp1(t, gpsOld, tNew);
The old signal will have about 8 times as many samples as your new signal. Of course if you want to average the values in a certain window so you'll take the average of all the extra values instead of just picking a sample, you'll have to do some other things, like preprocessing the signal with movmean to get a signal averaged over the window.
  2 Comments
Bugrahan Ustundag
Bugrahan Ustundag on 27 Aug 2022
Thank you for your answer, but I do not believe that I can read it into a time.
What I have is a complex sampled signal in a binary file.
You can find the binary files in this link: https://rnl-data.ae.utexas.edu/datastore/texbat/
For example, I want to resample ds4.bin file from 25Msps to 2.5Msps
Image Analyst
Image Analyst on 4 Sep 2022
OK, no problem. Looks like Star solved it for you (since you accepted his answer).

Sign in to comment.

Categories

Find more on Communications Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!