如何在 GNU Radio 中使用 MATLAB 文件作为文件源

How to use a MATLAB file as a file source in GNU Radio

我设计了一个滤波器,并在 MATLAB 中使用 SPTool 将其应用于随机噪声信号。我的噪音信号是 x = (1/sqrt(2))*(randn(1024,1)+j*randn(1024,1))

一旦我对这个噪声信号应用了我的滤波器,我怎样才能得到这个过滤后的信号并将它用作 GNU Radio Companion(我将连接到 QT GUI Frequency Sink)中的文件源?我尝试使用 SPTool 导出信号,但我不确定我可以为 GNU Radio 使用什么文件扩展名。提前致谢。

使用 fwrite 和正确的 precision 参数,可以得到浮动 32 个二进制文件。

或者只使用 octave/Matlab scripts in GNU Radio that do exactly that: write raw binary data. For more info, see the GNU Radio FAQ entry on the file format. (On https://wiki.gnuradio.org )

如果您有 .mat 文件,另一种选择是使用 Vector Source 块放入 Vector 字段:

loadmat('filename')['varname'].flatten()

为此,您需要:

import numpy
from scipy.io import loadmat

请注意,这会将整个文件加载到内存中(但如果出现问题,您可以指定从文件中加载哪些变量)。此外,如果数据存储为 float64(这是 Matlab 中的规范),那么我认为可能会有一些 rounding/truncation,因为 GR Vector Source 期望 float32(对 SWIG 如何处理它了解不够)。