How to import Simulink Simultion Output in Python

11 vues (au cours des 30 derniers jours)
Nick Froidl
Nick Froidl le 29 Jan 2021
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!

Réponses (1)

Kiran Felix Robert
Kiran Felix Robert le 1 Fév 2021
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.

Catégories

En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by