Export matlab workspace data to python
23 次查看(过去 30 天)
显示 更早的评论
Indhu Priyadharshini Govindasamy
2021-12-14
评论: Urveshkumar Dharmendrabhai
2023-5-2
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?
1 个评论
Urveshkumar Dharmendrabhai
2023-5-2
I am trying to control and simulate the simulink model through Python. However, I am getting the same error as below:
'ValueError: variable name is not valid in MATLAB'
I have written below code:
def getOutput(self):
simout_S = self.eng.workspace['out.simout']
tout_T = self.eng.workspace['out.tout']
return simout_S, tout_T
The error which I got is related the workspace variable. The workspace variable 'simout' is already defined in the simulink model.
How can I solve this problem? How can I extract results stored in the workspace into Python and plot them at the end?
For more information about my question, kindly see my question posted on the link below:
https://de.mathworks.com/matlabcentral/answers/1956564-valueerror-variable-name-is-not-valid-in-matlab-while-extracting-the-results-stored-in-matlab-wor
采纳的回答
更多回答(1 个)
Sanjay Sivakumar
2021-12-14
You can try to export the MATLAB workspace data to an excel spreadsheet and use the spreadsheet in python.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Python from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!