【发布时间】:2015-01-30 13:17:01
【问题描述】:
我正在使用 Matlab 函数方法为 Arduino Due 编写一个 simulink 设备驱动程序块,如 Simulink 设备驱动程序指南中所述。当我想使用 coder.ceval() 将 C++ 代码中的双精度数传递给 matlab 函数代码时,我得到一个错误的数字。这是一个例子:
C++ 函数:
#include <Arduino.h>
extern "C" double dout_output()
{
return 50.5;
}
Simulink 中的 Matlab 函数:
function x = example()
x = 0.0;
if strcmp(coder.target,'rtw'),
x = coder.ceval('dout_output');
end
当我在 adruino 上以外部模式运行此代码时,我没有得到 50.5,而是像 1113794816 这样的大数字。有什么建议吗?
【问题讨论】:
标签: c++ matlab arduino simulink matlab-coder