Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import / read / load variables from matlab matfile in C# [closed]

Tags:

c#

matlab

I've been searching for a while to see if anyone has done any work on reading Matlab mat files in CSharp, and it seems that there is nothing out there.

Has anybody seen any solutions?

I can't simply export my mat files to text and then read them into my C# code, because there are fairly complex structures.

I don't like to inter operate with Matlab and I don't want to use Python (SciPy with loadmat) either.

like image 884
Ali Avatar asked Nov 25 '10 22:11

Ali


People also ask

How do you import variables in MATLAB?

To load saved variables from a MAT-file into your workspace, double-click the MAT-file in the Current Folder browser. To load a subset of variables from a MAT-file on the Home tab, in the Variable section, click Import Data. Select the MAT-file you want to load and click Open.

How do you load variables from workspace in MATLAB?

load( filename ) loads data from filename . If filename is a MAT-file, then load(filename) loads variables in the MAT-file into the MATLAB® workspace. If filename is an ASCII file, then load(filename) creates a double-precision array containing data from the file.

How do you load a dataset in MATLAB?

Open the Import Tool MATLAB® Toolstrip: On the Home tab, in the Variable section, click Import Data. MATLAB command prompt: Enter uiimport( filename ) , where filename is a character vector specifying the name of a text or spreadsheet file.

How do I read a .data file in MATLAB?

Use fopen to open the file, specify the character encoding, and obtain the fileID value. When you finish reading, close the file by calling fclose(fileID) . A = fscanf( fileID , formatSpec , sizeA ) reads file data into an array, A , with dimensions, sizeA , and positions the file pointer after the last value read.


1 Answers

One option to try is the submission CSMatIO by David Zier on the MathWorks File Exchange. It's an API for .NET 2.0 that will allow you to read level 5 .mat files.

If you have to read newer .mat file formats, you can first load your .mat file into MATLAB and resave it as an older format using the SAVE function's version option.

like image 108
gnovice Avatar answered Sep 20 '22 06:09

gnovice