【发布时间】:2016-04-11 13:22:03
【问题描述】:
我是 Matlab 和 Simulink 的新手,我需要在 Raspberry PI 上运行仿真。对于交互,我使用 Matlab 的 Raspberry PI Support Package。我使用以下代码打开与 Raspberry PI 的连接并读取内部温度传感器:
mypi = raspi('hostname','username','password','port');
temperature = system(mypi,'command_to_read_temperature')
如果我在 Matlab 命令行中单独运行此代码,everythink 工作正常,但如果我尝试在 Simulink 的 Matlab 功能块中运行它,它会给我一个错误:
Base class 'matlab.mixin.CustomDisplay' cannot be loaded.
Function 'raspi.m' (#29.3176.7592), line 102, column 9:
"function obj = raspi(hostname, username, password, port)"
Launch diagnostic report.
Component: MATLAB Function | Category: Coder Error
有没有办法在 Matlab 功能块中运行带有 Raspberry PI 功能的代码?我尝试过使用 S-Function,但它过于复杂而且效果不佳。
【问题讨论】:
-
在 Simulink 中创建
mypi对象时,问题似乎已经显现。您是否尝试在 MATLAB 工作区上创建对象,然后直接在 Simulink 中使用它?我认为您应该可以从那里访问 MATLAB 的工作区变量。我知道这并不理想,但如果可行,可能会向前迈出一步。 -
感谢您的回复!我尝试在函数内部使用创建的对象,但出现错误:
undefined function or variable rpi。我认为您无法访问函数内部的变量是否可以将变量作为参数传递给 matlab 函数?
标签: linux matlab raspberry-pi simulink raspberry-pi2