Borrar filtros
Borrar filtros

How to import Simulink Simultion Output in Python

11 visualizaciones (últimos 30 días)
Nick Froidl
Nick Froidl el 29 de En. de 2021
Respondida: Kiran Felix Robert el 1 de Feb. de 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!

Respuestas (1)

Kiran Felix Robert
Kiran Felix Robert el 1 de Feb. de 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.

Categorías

Más información sobre Call Python from MATLAB en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by