It’s been a long time since I’ve busted out MATLAB / Simulink @Jacob265487
my MATLAB-fu is not strong anymore.
Googling your error message, pyrunfile may not be eligible for the task you want to do. It may be that you can’t execute pyrunfile
from within a simulink function block.
1 Like
Hello Michael,
You are right because it requests for code generation. However, is there any other way around it may be in python. Or else, I need to have the Simulink data offline for that task then run it in MATLAB to pass it to the DC load.
2 Likes
Hi Jacob,
What’s the project you are doing? Looks sick!
MatLab atleast can access your computers USB ports, and with a plugin like this: Instrument Control Toolbox Documentation - MathWorks Australia
If your project allows you might be able to use Python in its entirety.
Hello @Liam120347 and @Michael. Thanks for chipping in. Actually, its a ‘battery project’ of which the load profile is generated in real time as the simulation runs. The load profile is to be input to the DL3021A as load which is connected to a physical battery and discharges it based on the load profile passed into the DL3021A in real time. The first option was to use the Instrument Control Toolbox as you suggested which I tried but dropped because it wasn’t functioning as required also the device drivers in the toolbox are mainly for Keithley/Keysight instruments. Therefore, I resorted to Python which was a success, also linking the Python to MATLAB was fine. However, going back to the main goal of having stuff in Simulink using an m-file block whose input is the load profile, is where I am currently stuck.
Any clue around it will be appreciated.
2 Likes
@Jacob265487 your matlab / python script could write the values to a file.
Then you could use a separate python script running totally outside of MATLAB to handle reading that file and updating the load.
Put another way… You could write the new setpoint to the file and save
when the file is updated, another script could read the last line entry and send that setpoint to the Load.
2 Likes
Hello @Michael thanks for the reply and guidance. Let me try 'Accessing the Data in a MATLAB Function During Simulation’ with a call-back function in the instrumentation signal properties.
Thank you.
2 Likes