You can then use the following C# code to get this data into a .NET double-Array:
namespace csmatio_test
{
using System;
using csmatio.io;
using csmatio.types;
class Program
{
// this array receives the matlab data
static double[] squares;
static void Main(string[] args)
{
// create a reader for the file
MatFileReader mfr = new MatFileReader("mydata.mat");
// get a reference to out matlab 'squares' double matrix
MLDouble mlSquares = (mfr.Content["squares"] as MLDouble);
if (mlSquares != null)
{
// now get the double values
double[][] tmp = mlSquares.GetArray();
squares = tmp[0];
}
}
}
}
Hi farid, csmatio uses zlib to compress/decompress matlab file data. There are several possibilities why zlib throws this exception; for example you might think of
(a) file format not supported (csmatio does not support all kinds of mat files)
(b) corrupt file content
(c) bug in csmatio
...
hi all.
I'm trying to read a mat file but i receive this error
==========================
Error in reading MAT-file 'initialize\matfile-1.mat':
csmatio.io.MatlabIOException: Could not decompress data: zlib.ZStreamException: inflating:
at zlib.ZOutputStream.Write(Byte[] b1, Int32 off, Int32 len)
at csmatio.io.MatFileReader.Inflate(Stream buf, Int32 numOfBytes)
at csmatio.io.MatFileReader.Inflate(Stream buf, Int32 numOfBytes)
at csmatio.io.MatFileReader.ReadData(Stream buf)
at csmatio.io.MatFileReader..ctor(String fileName, MatFileFilter filter)
==========================
what is the cause of this error message?
pleas help .... the situation is urgent!