How can I directly import a MAT file into an excel sheet, bypassing MATLAB?
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 10 Sep. 2012
Bearbeitet: MathWorks Support Team
am 16 Feb. 2021
Is there a way where I can directly import a MAT file into an excel sheet, bypassing MATLAB. I do not want to use MATLAB functions to load a MAT file into an excel sheet.
Akzeptierte Antwort
MathWorks Support Team
am 16 Feb. 2021
Bearbeitet: MathWorks Support Team
am 16 Feb. 2021
It is possible to import a MAT file into an excel sheet directly by using one of the following workarounds:
1) MATLAB Compiler( In R2014b and earliear version, MATLAB Builder EX) can be used to create an Excel Add-in which would perform the same.
2) Spreadsheet Link can be used to import a MAT file but would require MATLAB in the background.
3) The third option is to use the MAT file API, which is a set of libraries, using which you can call the MAT file API in a VBA application in order to import MAT files directly into Excel environment.
More information on MAT file API can be found in the link below
In order to use the above workaround, you would have to write VBA code to access the functions in the DLL. You would have to create a wrapper DLL, which is another C/C++ DLL that access the DLL as shown in the below example matcreat.c
The Wrapper DLL would then expose functions that can be called from VBA.
The format would be similar to the below code:
Private Declare Function matOpen Lib "libmat.dll" (filename As String, mode As String) As Long
Private Declare Function matClose Lib "libmat.dll" (mfp As Long) As Integer
Private Declare Function matGetVariable Lib "libmat.dll" (mfp As Long, name As String) As Long
Sub test()
matHandle = matOpen("C:\LocalData\Requests\Excel_MAT\test.mat", "r")
Call matClose(matHandle)
End Sub
But instead of using the libmat.dll, wrapper DLL must be used.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Export to MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!