You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#region
//MathNet.Numerics, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null
//MathNet.Numerics.Data.Matlab, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null
#endregion
I use the following code to generate a mat file
public static string WriteMatFile(double[,] data, string matFile)
{
Matrix<double> m = DenseMatrix.OfArray(data);
using (FileStream fs = new FileStream(matFile, FileMode.Create))
{
MatlabWriter.Write(fs, m,Path.GetFileNameWithoutExtension(matFile));
};
return matFile;
}
I encountered an error reading the file using a Python script
import scipy.io as scio
data = scio.loadmat("test.mat")
print('data:\n',data)
print('datatype:\n',type(data))
print('keys:\n',data.keys)
print('keys:\n',data.keys())
print(data['EKG'])
print('target shape\n',data['EKG'].shape)
F:\home> & C:/Users/jt/AppData/Local/Programs/Python/Python312/python.exe f:/home/test.py
Traceback (most recent call last):
File "f:\home\test.py", line 2, in
data = scio.loadmat("test.mat")
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio.py", line 227, in loadmat
matfile_dict = MR.get_variables(variable_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio5.py", line 330, in get_variables
res = self.read_var_array(hdr, process)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio5.py", line 290, in read_var_array
return self._matrix_reader.array_from_header(header, process)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "_mio5_utils.pyx", line 665, in scipy.io.matlab._mio5_utils.VarReader5.array_from_header
File "_mio5_utils.pyx", line 694, in scipy.io.matlab._mio5_utils.VarReader5.array_from_header
File "_mio5_utils.pyx", line 768, in scipy.io.matlab._mio5_utils.VarReader5.read_real_complex
File "_mio5_utils.pyx", line 445, in scipy.io.matlab._mio5_utils.VarReader5.read_numeric
File "_mio5_utils.pyx", line 350, in scipy.io.matlab._mio5_utils.VarReader5.read_element
File "_streams.pyx", line 171, in scipy.io.matlab._streams.ZlibInputStream.read_string
File "_streams.pyx", line 147, in scipy.io.matlab._streams.ZlibInputStream.read_into
File "_streams.pyx", line 134, in scipy.io.matlab._streams.ZlibInputStream._fill_buffer
zlib.error: Error -3 while decompressing data: incorrect data check
The text was updated successfully, but these errors were encountered:
#region
//MathNet.Numerics, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null
//MathNet.Numerics.Data.Matlab, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null
#endregion
I use the following code to generate a mat file
I encountered an error reading the file using a Python script
F:\home> & C:/Users/jt/AppData/Local/Programs/Python/Python312/python.exe f:/home/test.py
Traceback (most recent call last):
File "f:\home\test.py", line 2, in
data = scio.loadmat("test.mat")
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio.py", line 227, in loadmat
matfile_dict = MR.get_variables(variable_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio5.py", line 330, in get_variables
res = self.read_var_array(hdr, process)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jt\AppData\Local\Programs\Python\Python312\Lib\site-packages\scipy\io\matlab_mio5.py", line 290, in read_var_array
return self._matrix_reader.array_from_header(header, process)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "_mio5_utils.pyx", line 665, in scipy.io.matlab._mio5_utils.VarReader5.array_from_header
File "_mio5_utils.pyx", line 694, in scipy.io.matlab._mio5_utils.VarReader5.array_from_header
File "_mio5_utils.pyx", line 768, in scipy.io.matlab._mio5_utils.VarReader5.read_real_complex
File "_mio5_utils.pyx", line 445, in scipy.io.matlab._mio5_utils.VarReader5.read_numeric
File "_mio5_utils.pyx", line 350, in scipy.io.matlab._mio5_utils.VarReader5.read_element
File "_streams.pyx", line 171, in scipy.io.matlab._streams.ZlibInputStream.read_string
File "_streams.pyx", line 147, in scipy.io.matlab._streams.ZlibInputStream.read_into
File "_streams.pyx", line 134, in scipy.io.matlab._streams.ZlibInputStream._fill_buffer
zlib.error: Error -3 while decompressing data: incorrect data check
The text was updated successfully, but these errors were encountered: