File: save_csv.m

package info (click to toggle)
bladerf 0.2024.05-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 245,984 kB
  • sloc: ansic: 361,923; vhdl: 28,167; tcl: 14,424; python: 3,668; sh: 1,811; makefile: 1,255; xml: 1,020; cpp: 473; asm: 158; csh: 18
file content (22 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function save_csv(filename, signal)
% SAVE_SC16Q11 Write a normalized complex signal to a CSV file in the
%              as integer bladeRF "SC16 Q11" values.
%
%   FILENAME is the target filename. The file will be overwritten if it
%   already exists.
%
%   SIGNAL is a complex signal with the real and imaginary components
%   within the range [-1.0, 1.0).

    sig_i = round(real(signal) .* 2048.0);
    sig_i(sig_i > 2047)  = 2047;
    sig_i(sig_i < -2048) = -2048;

    sig_q = round(imag(signal) .* 2048.0);
    sig_q(sig_q > 2047)  = 2047;
    sig_q(sig_q < -2048) = -2048;

    sig = [sig_i sig_q];
    csvwrite(filename, sig);
end