How to import Simulink Simultion Output in Python

8 ビュー (過去 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 Center および File ExchangeCall 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