How can I save Python dictionaries in Matlab?

조회 수: 8 (최근 30일)
Leah
Leah 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
What is the simplest way to send complex data from Matlab to Python? I have a pre-written script in Python that uses dictionaries as the base data form and it would be difficult to change this. I know py.dict exists in Matlab but up to this point I've found no way to save the dictionary in Matlab and re-open it in Python. If all scripts were just written in Python, I could use a Pickle file to do this but, as far as I can tell, there is no equivalent in Matlab, and I'm dependent on a Matlab only toolbox to get the data. Is there a way to send more complex dataforms than an array from Matlab to Python?

답변 (1개)

Stephen23
Stephen23 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
A simple approach:
  1. within MATLAB save the data in a .mat file.
  2. within Python load the data using numpy.io.
  3. rearrange the data into the structure that you need.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by