How to import Simulink Simultion Output in Python

조회 수: 11 (최근 30일)
Nick Froidl
Nick Froidl 2021년 1월 29일
답변: Kiran Felix Robert 2021년 2월 1일
Hello,
i have a easy Simulink Model, e.g. like in Simulink_1 picture! 3 Inputs and 2 Outputs. This is only a part of a bigger Project but when I run this file, of course Output 1 and 2 have Value 0 because no inputs are given. But I have this testvariable which gives out the Value "5" into the Workspace!
Now I have this "out" in my Workspace (Picture 2). When I open it it looks like in Picture 3.
Now I want to "Export" e.g. the Value of "Testvariable" into Python. I tried so much but I didnt get the solution. Please help me!

답변 (1개)

Kiran Felix Robert
Kiran Felix Robert 2021년 2월 1일
Hi Nick,
You can try exporting the simulation data from MATLAB to either an MAT-file or a .csv file, which can be imported into python.
You can access the testvariable data using the following code,
dataXport = out.testvariable.Data;
Now export the data in the variable ‘dataXport’ to a csv file using
writematrix(dataXport,'filename.csv')
filename.csv can be imported to python.

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by