Rank: 1204 based on 57 downloads (last 30 days) and 1 file submitted
Personal Profile:
Professional Interests:
Computer Architecture, Digital Signal Processing, Systems Engineering

 

Watch this Author's files

 

Files Posted by David
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Sep 2007 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier net, io, matfile, mat, c, external interface 57 15
  • 3.71429
3.7 | 7 ratings
Comments and Ratings on David's Files View all
Updated File Comment by Comments Rating
07 Dec 2011 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier W, Markus

Had problems reading mat-files with 2-dim arrays with larger number of elements. Saving the file with -v6 option solved the problem (so far).

01 Nov 2011 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier Otto-Adamczak, Tobias

Hi Qirong, I give you a very simple but more complete example. I tested this with Matlab R2006b and Visual Studio 2005.

Consider you created a "mydata.mat" file containing a 1x10 double matrix using matlab like this:

>> squares = [1:10].^2
>> save('mydata.mat', 'squares')

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];
            }
        }
    }
}

HTH, Tobias

01 Nov 2011 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier Otto-Adamczak, Tobias

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
...

28 Oct 2011 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier Qirong

So I know that the data is double array, how can I cast the MLArray type into MLDouble type? I tried

MatFileReader mfr = new MatFileReader(currentName);
            foreach (MLArray mla in mfr.Data)
            {
                MLDouble da = mla;
            }

But apparently this doesn't work...

28 Oct 2011 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier farid

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!

Top Tags Applied by David
api, c, external interface, io, mat
Files Tagged by David
Updated   File Tags Downloads
(last 30 days)
Comments Rating
11 Sep 2007 CSMatIO: MAT-file I/O API for .NET 2.0 Package contains Matlab's MAT-File I/O API for .NET 2.0. Supports Matlab 5 MAT-file format. Author: David Zier net, io, matfile, mat, c, external interface 57 15
  • 3.71429
3.7 | 7 ratings

Contact us at files@mathworks.com