gpt4 book ai didi

linux - 在 Simulink 中使用 Matlab Raspberry PI Support Package 函数作为 Matlab Function Block

转载 作者:太空狗 更新时间:2023-10-29 12:28:26 24 4
gpt4 key购买 nike

我是 Matlab 和 Simulink 的新手,我需要在 Raspberry PI 上运行仿真。对于交互,我使用 Matlab 的 Raspberry PI 支持包。我使用以下代码打开与 Raspberry PI 的连接并读取内部温度传感器:

mypi = raspi('hostname','username','password','port');
temperature = system(mypi,'command_to_read_temperature')

如果我在 Matlab 命令行中单独运行此代码,一切正常,但如果我尝试在 Simulink 中的 Matlab 功能 block 中运行它,它会返回一个错误:

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 函数 block 中运行带有 Raspberry PI 函数的代码吗?我尝试使用 S-Functions,但它太复杂了,而且效果不是很好。

最佳答案

虽然我不明白究竟是什么导致了错误,但我可以解释为什么它不能那样工作。

MATLAB 的 Raspberry 支持包旨在将 Raspberry 用作 IO 板,并在 MATLAB 中提供传感器和执行器。该应用程序本身在您的 PC 上运行。命令 mypi = raspi('hostname','username','password','port'); 设置此连接。

您尝试做其他事情,让应用程序在树莓派上运行。对于此用例,Simulink 和 simulink 的支持包是正确的选择。这些 block 同时支持这两种功能,使用网络连接在您的 PC 上模拟应用程序以访问传感器和执行器,或在树莓派上运行应用程序,直接将 IO 构建到您的应用程序中。

关于linux - 在 Simulink 中使用 Matlab Raspberry PI Support Package 函数作为 Matlab Function Block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34650297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com