Is it possible to read/write MAT files from a C# application?
74 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2012-4-25
编辑: MathWorks Support Team
2024-5-7
I would like to develop a C# application that is able to import and export MAT files compatible with MATLAB 7.14 (R2012a).
采纳的回答
MathWorks Support Team
2024-5-7
编辑:MathWorks Support Team
2024-5-7
MAT-file APIs are only available for Fortran and the C/C++ languages.
So one option here could be to develop a wrapper .NET Assembly around these interfaces using managed C++. On the one end this could make use of the C/C++ MAT-file API and on the other end it could provide a .NET interface which you could easily access from C# code.
One workaround where you do not make use of the MAT-file API is to access MAT files using the Builder NE toolbox to build a .NET assembly.
The idea is to write some simple MATLAB functions that load a given MAT file into the workspace, then return the data. Then you can deploy these functions using Builder NE into a .NET assembly.
In your C# code, you can then reference the deployed .NET assembly and call your written functions, which will return the data back as MWArray objects in your C# code. You can manipulate the MWArray objects to obtain native arrays and other data.
The MWArray class reference is included below:
An alternative workaround is writing C# code which creates and reads MAT-files on a binary level. To do this, please refer to the following MAT file format document:
The following page is an example of a C# implementation from a third party user:
Note that this library is not developed or supported by MathWorks and if you need assistance using it, please contact the author directly.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call MATLAB from .NET 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!