Export matlab workspace data to python

19 ビュー (過去 30 日間)
Indhu Priyadharshini Govindasamy
Indhu Priyadharshini Govindasamy 2021 年 12 月 14 日
i want to export matlab workspace data to python and plot the graph in python
eng.sim("add.slx")
myVar = eng.workspace["out.simout.Data"]
print(myVar)
but i am getting this ValueError: variable name is not valid in MATLAB.
Could anyone please help me to solve this?

採用された回答

Indhu Priyadharshini Govindasamy
Indhu Priyadharshini Govindasamy 2021 年 12 月 16 日
eng.eval('a = out.simout;',nargout=0)
mpi = eng.workspace['a']
print(mpi)
adding eval worked for me

その他の回答 (1 件)

Sanjay Sivakumar
Sanjay Sivakumar 2021 年 12 月 14 日
You can try to export the MATLAB workspace data to an excel spreadsheet and use the spreadsheet in python.
  1 件のコメント
Indhu Priyadharshini Govindasamy
Indhu Priyadharshini Govindasamy 2021 年 12 月 14 日
Thank you for your reply. i will try this
@Deepak Meena replied like we can use this line of code to access the workspace variable in python.
p = eng.workspace['out.simout'];
but i dont know why it is not working in my case.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by