How to import Simulink Simultion Output in Python
8 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from Python 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!