I'm new to Matlab and Simulink and I need to get a simulation run on the Raspberry PI. For interaction I use the Raspberry PI Support Package of Matlab. I use the following code to open the connection to the Raspberry PI and read the internal temperature sensor:
mypi = raspi('hostname','username','password','port');
temperature = system(mypi,'command_to_read_temperature')
If I run this code separately in the Matlab command line everythink works fine but if I try to run it in a Matlab function block in Simulink it gives me back an error:
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
Is there any way to run code with functions for Raspberry PI in a Matlab function block? I tried with S-functions, but it is way to complicated and complex and didn't work out very well.
mypi
object in Simulink. Did you try to create the object on the MATLAB workspace, and then just use it directly in Simulink? I think you should have access to MATLAB's workspace variables from there. I know it's not ideal, but maybe a step forward if it works. – mikkolaundefined function or variable rpi
. I think you can't access the variable inside the function is it possible to pass a variable as parameter to an matlab function? – user4947869