Search code examples
gomat-file

Is it possible to read .mat files in Go?


I'd like to load a MATLAB file that stores a 1x1 struct with 4 fields using Go. I haven't found anything comparable to Python's SciPy which has a "loadmat" function. What is the best way to read .mat files in Go?


Solution

  • You may have to write your own Go package. MathWorks suggests that you interface with their MATLAB MAT-file C API. To do that in Go, use cgo.

    References:

    MATLAB MAT-File Format - MathWorks

    Command cgo

    C? Go? Cgo!