Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在MATLAB R2011b和Python(Windows 7)之间传递数据_Python_Matlab_Python 2.7_Parameter Passing_Language Interoperability_Hdf5 - Fatal编程技术网

在MATLAB R2011b和Python(Windows 7)之间传递数据

在MATLAB R2011b和Python(Windows 7)之间传递数据,python,matlab,python-2.7,parameter-passing,language-interoperability,hdf5,Python,Matlab,Python 2.7,Parameter Passing,Language Interoperability,Hdf5,朋友们好, 我想在MATLAB和Python之间传递数据,一种方法是在Python中使用MATLAB.engine或从MATLAB调用Python库。但这种方法需要Matlab2014版本,而我的版本是MatlabR2011B 因此,我请求您提供一种不同的方法,以便在Python和MatlabR2011B版本之间进行通信 提前感谢根据您想要做的事情和您的数据类型,您可以将其写入文件并用其他语言读取。您可以在python部分中使用numpy.fromfile。两者都支持,并且支持二进制文件格式。

朋友们好,

我想在MATLAB和Python之间传递数据,一种方法是在Python中使用MATLAB.engine或从MATLAB调用Python库。但这种方法需要Matlab2014版本,而我的版本是MatlabR2011B

因此,我请求您提供一种不同的方法,以便在Python和MatlabR2011B版本之间进行通信


提前感谢

根据您想要做的事情和您的数据类型,您可以将其写入文件并用其他语言读取。您可以在python部分中使用numpy.fromfile。两者都支持,并且支持二进制文件格式。 您可以使用/,在matlab中读取/写入hdf5数据文件:

在python中,您有:

反过来说:

import h5py, numpy as np

with h5py.File('./data_from_python.h5', 'w') as W:
    W.create_dataset(name='data', data=np.zeros((10,10),dtype='f4'))
在Matlab中进行数据挖掘和阅读

>> data = hdf5read('./data_from_python.h5','/data');  % you might need to remove '/' from '/data'...

感谢Shai的快速响应。我试过了,但我只能在MATLAB中创建.h5文件,但当我尝试在Ipython中读取时,我无法…错误是:无法打开file@Abhishek文件存在吗?您是否具有对所创建文件的读取权限?文件是否可能已损坏?如果你输入shell h5ls,你会看到什么?是的,我在MATLAB中创建了,当我输入cmd时…它给出了路径和数据,带有{10,10}现在我交叉检查,文件存在于该位置,但无法在python中打开,带有h5py.FileComplete链接,带有“/”分隔。/data_from_MATLAB.h5,'r'作为r:x=np.arrayR['与'/'分离数据'的完整链接]但是得到了KeyError:“无法打开objectComponent not found”感谢UpSampler的创造性方法。实际上,我的数据文件的实际格式是.dat。所以如何读取这样的文件,我尝试了xls方式导入,但没有找到因为文件大小为350MB
import h5py, numpy as np

with h5py.File('./data_from_python.h5', 'w') as W:
    W.create_dataset(name='data', data=np.zeros((10,10),dtype='f4'))
>> data = hdf5read('./data_from_python.h5','/data');  % you might need to remove '/' from '/data'...