简体   繁体   English

Octave 中的重采样功能?

[英]resample function in Octave?

I am trying to convert a MATLAB script into an Octave file.我正在尝试将 MATLAB 脚本转换为 Octave 文件。 I am using Octave 4.0.我正在使用 Octave 4.0。

In the MATLAB script, I encountered a line with the format resample (X, tx, fx).在 MATLAB 脚本中,我遇到了格式为resample (X, tx, fx) 的一行。 Is there any equivalent function in Octave for this resample function?这个重采样函数在 Octave 中是否有任何等效的函数?

I am not looking for the function resample (X, p, q).我不是在寻找函数resample (X, p, q)。

As per the Mathworks website: y = resample(x,p,q) resamples the input sequence, x, at p/q times the original sample rate.根据 Mathworks 网站: y = resample(x,p,q) 以原始采样率的 p/q 倍对输入序列 x 重新采样。 y = resample(x,tx,fs) uses a polyphase antialiasing filter to resample the signal at the uniform sample rate specified in fs. y = resample(x,tx,fs) 使用多相抗混叠滤波器以 fs 中指定的均匀采样率重新采样信号。

Please type in Octave:请输入八度:

 >>  help resample

Answer will be (in my computer I have installed this package before):答案将是(在我的电脑中我之前已经安装了这个包):

error: help: the 'resample' function belongs to the signal package from Octave Forge which you have installed but not loaded.错误:帮助:'resample' 函数属于您已安装但未加载的 Octave Forge 信号包。 To load the package, run `pkg load signal' from the Octave prompt.要加载包,请从 Octave 提示符运行“pkg load signal”。

You must install and load signal package .您必须安装和加载信号包 See instructions in file README.html in root Octave directory (example from Windows distributive):请参阅 Octave 根目录中文件 README.html 中的说明(来自 Windows 发行版的示例):

  • Run the script build_packages.m to build and install the packages.运行脚本 build_packages.m 来构建和安装包。 Installation is a one-time procedure.安装是一次性过程。 After installation packages must still be loaded in order to use them with the pkg load PACKAGENAME command.安装包后仍必须加载,以便与 pkg load PACKAGENAME 命令一起使用。

In the documentation here it says there is one.此处的文档中它说有一个。 You should be able to use it like below like in documentation.您应该可以像在文档中一样使用它。

[y, h] = resample (x, p, q)

For those who need the non-uniform to uniform resampling that Matlab's resample() provides but Octave's resample() does not, you can use interp1() instead.对于那些需要 Matlab 的resample()提供但 Octave 的resample()不提供的非统一到统一重采样的人,您可以使用interp1()代替。

 y = resample(X, tx, fs)

can be converted as可以转换为

 samplecount = (max(tx) - min(tx)) * fs
 y = interp1(tx, X, linspace(min(tx), max(tx), samplecount))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM