How can I directly import a MAT file into an excel sheet, bypassing MATLAB?

150 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Feb 2021
Edited: MathWorks Support Team on 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.

More Answers (0)

Categories

Find more on Data Export to MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!