So let’s start off by saying I’m a total beginner in matlab. I’m working with python and now I’ve recieved some data in a matlab file that I need to export to a format I could use with python.
I’ve googled around and found I can export a matlab variable to a text file using:
dlmwrite('my_text', MyVariable, 'delimiter' , ',');
Now the variable I need to export is a 16000 x 4000 matrix of doubles of the form 0.006747668446927. Now here is where the problem starts. I need to export the full values for each double. Trying with that function lead me to export the numbers in a format of 0.0067477. This won’t do since I need a whole lot more of precision for what I’m doing. So how can I export the full values of each of these variables? Or if you have a more elegant way of using that huge matlab matrix in python please feel free.
Regards,
Bogdan
To exchange big chunks of numerical data between Python and Matlab I
recommend HDF5
The Python binding is called h5py
Here are two examples for both directions. First from
Matlab to Python
And now from Python to Matlab
NOTE A column in Matlab will come out as a row in Python and vice versa. This isn’t a bug but the difference between the way C and Fortran interpret a continuous piece of data in memory.