【问题标题】:Matlab code generation of resample: the number of terms N must be constantmatlab代码生成重采样:项数N必须是常数
【发布时间】:2019-03-27 05:46:49
【问题描述】:

我使用 Matlab coder 生成以下函数的 C 代码:

function [out] = myresample(in)
    out = resample(in,4644,1000,10);
end

并通过codegen myresample -args {coder.typeof(0, [1 Inf]), 0} -config cfg生成代码,其中cfg = coder.config('lib')cfg.DynamicMemoryAllocation = 'AllVariableSizeArrays'

但它报告错误为:

??? The number of terms N must be constant.

我很困惑为什么它是错误的。有趣的是,当我将功能更改为

function [out] = myresample(in)
    out = resample(in,10,10,10);
end

它有效。

我发现some links 解释了如何生成resample 的代码。但这似乎不适用于我的情况。

我使用 Matlab 2017b。

谢谢。

【问题讨论】:

    标签: matlab matlab-coder


    【解决方案1】:

    根据Matlab 2017b documentation

    C/C++ 代码生成:使用 MATLAB® Coder™ 生成 C 和 C++ 代码。
    使用说明和限制:
    重新采样的 C 和 C++ 代码生成需要 DSP System Toolbox™ 软件。 上采样和下采样因子必须指定为常数。如果表达式或变量的值不变,则允许使用它们。
    不支持可变大小的输入。

    在您的代码中,in 的大小不受限制。

    在您的函数myresample 中,您应该尝试指定一个限制。比如:

    limited_in = in(1:128);
    out = resample(limited_in,4644,1000,10);
    

    因此resample 的输入大小将始终保持不变。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-16
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-18
      相关资源
      最近更新 更多