Access block output data from simulink in python

3 Ansichten (letzte 30 Tage)
Suvrat Ramasubramanian
Suvrat Ramasubramanian am 4 Mär. 2020
Hi All,
I am trying to run a simulink model form python using matlab engine. I am able to load the model and data in the workspace and run the simulation. I would like to read the outputs of a subsytem block from the simulink model during simulation that I can then use in python.
I tried using the add_exec_event_listener function in the startFcn callback of the subsystem
blk = 'path/to/the/subsystem'
add_exec_event_listener(blk,'PostOutputs',@readsubsysdata)
where readsubsysdata.m is
function [data1] = readsubsysdata(block,~)
data1 = block.outport(1).data;
end
How do I read the data from the block in python during the simulation? I am not sure if I completely follow the steps of doing so.
Thanks in advance!

Antworten (0)

Kategorien

Mehr zu Call MATLAB from Python finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by