Python Forum

Full Version: How can I save Python dictionaries in Matlab?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?
It depends on what the term complex data means?!
I didn't work with MatLab for a long time, but I think json format would be a good choice to transfer data between Python and MatLab (and vice versa). You can communicate with Python program via TCP/IP by sending json-encoded data. Python program will listen on a specific port and process sent data. As I said, I don't touch MatLab for a long time, may be some MatLab Toolbox already developed to interact with Python program in more convenient way.