无法在Matlab编码器中传递文字常量
cannot pass a literal constant in Matlab Coder
我正在使用Matlab Coder生成C++代码。它在所示代码的最后一行给出一个错误:
function [Xs Ys]=sc(X, Y, r)
...
xGauss=gausswin(2*r+1,5));
如果是类似的东西就好了
xGauss=gausswin(11,5));
所以我尝试了两种方法,一种是
xGauss=coder.const(@gausswin,2*r+1,5);
但它说"coder.const是未定义的"。另一种方法是放置编码器。变量r为常量,但它再次失败。在windows上,它是"coder.Constant"类不支持代码生成。在Linux上,它的"coder.Constant"不是支持的枚举。对于代码生成,枚举必须继承自"int32"或"Simulink.IntEnumType"。"如何解决此问题?"?
我用代替gausswin解决了这个问题
function w = gausswin_2(L, a)
N = L-1;
n = (0:N)'-N/2;
w = exp(-(1/2)*(a*n/(N/2)).^2);
end
相关文章:
- 常量函数,当其参数是对文字类型的引用时
- 为什么文字不是常量(字符串除外)?
- 模板接受常量,但不接受文字
- C++ 常量指向文字的指针有效吗?
- 为什么对字符串参数的常量引用可以采用字符串文字?
- 字符串文字可以传递给接受常量字符*的函数吗?
- 是否将常量字符*设置为等于字符[]文字安全
- 文字符号和字符串变量之间的串联然后返回常量字符*
- 字符串文字绑定到一个非常量字符指针
- 从文字字符串生成编译时常量整数
- 不以nul结尾的常量字符串文字
- Visual Studio 2015字符串文字并不总是常量
- 其中C++内存中的文字常量存储
- 为什么不允许我将函数返回 const char* 的结果分配给 char*,bt 可以将字符串文字(常量)分配给 cha
- 以前定义的常量,作为宏参数给出,被认为是字符串文字
- 我是否应该为代码中的重复文字定义常量
- 为什么字符常量/文字不能为空?
- 指针和文字常量
- 如何写出像"size_t s = 16 MByte"这样的文字常量?
- 无法在Matlab编码器中传递文字常量