Access block output data from simulink in python

조회 수: 2 (최근 30일)
Suvrat Ramasubramanian
Suvrat Ramasubramanian 2020년 3월 4일
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!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call MATLAB from Python에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by