{"id":39589754,"url":"https://github.com/scigolib/matlab","last_synced_at":"2026-04-05T09:01:23.516Z","repository":{"id":298486922,"uuid":"999698552","full_name":"scigolib/matlab","owner":"scigolib","description":"Pure Go library for reading and writing MATLAB .mat files (v5-v7.3+). No CGo, no external dependencies. Full support for numeric types, complex numbers, and multi-dimensional arrays. Cross-platform (Windows/Linux/macOS). Part of SciGoLib ecosystem.","archived":false,"fork":false,"pushed_at":"2026-03-31T07:34:22.000Z","size":161,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-03T05:39:39.644Z","etag":null,"topics":["cross-platform","data-science","go","golang","hdf5","mat-files","matlab","no-cgo","octave","pure-go","scientific-computing","scientific-data"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/scigolib/matlab","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scigolib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-10T16:43:33.000Z","updated_at":"2026-03-31T07:32:26.000Z","dependencies_parsed_at":"2026-03-04T10:01:06.382Z","dependency_job_id":null,"html_url":"https://github.com/scigolib/matlab","commit_stats":null,"previous_names":["scigolib/matlab"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/scigolib/matlab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scigolib%2Fmatlab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scigolib%2Fmatlab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scigolib%2Fmatlab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scigolib%2Fmatlab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scigolib","download_url":"https://codeload.github.com/scigolib/matlab/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scigolib%2Fmatlab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31430011,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T08:13:15.228Z","status":"ssl_error","status_checked_at":"2026-04-05T08:13:11.839Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-platform","data-science","go","golang","hdf5","mat-files","matlab","no-cgo","octave","pure-go","scientific-computing","scientific-data"],"created_at":"2026-01-18T07:42:45.177Z","updated_at":"2026-04-05T09:01:23.499Z","avatar_url":"https://github.com/scigolib.png","language":"Go","readme":"# MATLAB File Reader/Writer for Go\n\n\u003e **Pure Go implementation for reading AND writing MATLAB `.mat` files** - No CGo required\n\n[![GitHub Release](https://img.shields.io/github/v/release/scigolib/matlab?include_prereleases\u0026style=flat-square\u0026logo=github\u0026color=blue)](https://github.com/scigolib/matlab/releases/latest)\n[![Go Version](https://img.shields.io/badge/Go-1.25%2B-00ADD8?style=flat-square\u0026logo=go)](https://go.dev/dl/)\n[![Go Reference](https://pkg.go.dev/badge/github.com/scigolib/matlab.svg)](https://pkg.go.dev/github.com/scigolib/matlab)\n[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/scigolib/matlab/test.yml?branch=main\u0026style=flat-square\u0026logo=github-actions\u0026label=CI)](https://github.com/scigolib/matlab/actions)\n[![Codecov](https://img.shields.io/codecov/c/github/scigolib/matlab?style=flat-square\u0026logo=codecov)](https://codecov.io/gh/scigolib/matlab)\n[![Go Report Card](https://goreportcard.com/badge/github.com/scigolib/matlab?style=flat-square)](https://goreportcard.com/report/github.com/scigolib/matlab)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n[![GitHub Stars](https://img.shields.io/github/stars/scigolib/matlab?style=flat-square\u0026logo=github)](https://github.com/scigolib/matlab/stargazers)\n[![GitHub Issues](https://img.shields.io/github/issues/scigolib/matlab?style=flat-square\u0026logo=github)](https://github.com/scigolib/matlab/issues)\n[![Discussions](https://img.shields.io/github/discussions/scigolib/matlab?style=flat-square\u0026logo=github\u0026color=purple)](https://github.com/scigolib/matlab/discussions)\n\n---\n\nA modern, pure Go library for **reading and writing** MATLAB `.mat` files without CGo dependencies. Part of the [SciGoLib](https://github.com/scigolib) scientific computing ecosystem.\n\n## Features\n\n✨ **Read \u0026 Write Support**\n- 📖 Read MATLAB v5-v7.2 files (traditional format)\n- 📖 Read MATLAB v7.3+ files (HDF5 format)\n- ✍️ **Write MATLAB v7.3+ files** (HDF5 format)\n- ✍️ **Write MATLAB v5-v7.2 files** (traditional format) - **NEW in v0.2.0!**\n\n🎯 **Key Capabilities**\n- Simple, intuitive API\n- Zero external C dependencies\n- Type-safe data access\n- Comprehensive error handling\n- Round-trip verified (write → read → verify)\n\n📊 **Data Types**\n- All numeric types (double, single, int8-64, uint8-64)\n- Complex numbers\n- Multi-dimensional arrays\n- Character arrays\n- Structures\n- Cell arrays\n- Sparse matrices\n- Compressed data (reading)\n\n## Installation\n\n```bash\ngo get github.com/scigolib/matlab\n```\n\n## Quick Start\n\n### Reading MAT-Files\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/scigolib/matlab\"\n)\n\nfunc main() {\n\t// Open MAT-file\n\tfile, err := os.Open(\"data.mat\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer file.Close()\n\n\t// Parse MAT-file (auto-detects v5 or v7.3)\n\tmat, err := matlab.Open(file)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Access variables\n\tfor _, v := range mat.Variables {\n\t\tfmt.Printf(\"%s: %s %v\\n\", v.Name, v.DataType, v.Dimensions)\n\n\t\t// Access data based on type\n\t\tif data, ok := v.Data.([]float64); ok {\n\t\t\tfmt.Println(\"Data:\", data)\n\t\t}\n\t}\n}\n```\n\n### Writing MAT-Files\n\n#### v7.3 Format (HDF5-based)\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/scigolib/matlab\"\n\t\"github.com/scigolib/matlab/types\"\n)\n\nfunc main() {\n\t// Create new MAT-file (v7.3 format)\n\twriter, err := matlab.Create(\"output.mat\", matlab.Version73)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer writer.Close()\n\n\t// Write a variable\n\terr = writer.WriteVariable(\u0026types.Variable{\n\t\tName:       \"mydata\",\n\t\tDimensions: []int{3, 2},\n\t\tDataType:   types.Double,\n\t\tData:       []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Write complex numbers\n\terr = writer.WriteVariable(\u0026types.Variable{\n\t\tName:       \"z\",\n\t\tDimensions: []int{2},\n\t\tDataType:   types.Double,\n\t\tIsComplex:  true,\n\t\tData: \u0026types.NumericArray{\n\t\t\tReal: []float64{1.0, 2.0},\n\t\t\tImag: []float64{3.0, 4.0},\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n#### v5 Format (Traditional Binary) - **NEW in v0.2.0!**\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\n\t\"github.com/scigolib/matlab\"\n\t\"github.com/scigolib/matlab/types\"\n)\n\nfunc main() {\n\t// Create new MAT-file (v5 format - legacy compatible)\n\twriter, err := matlab.Create(\"output_v5.mat\", matlab.Version5)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer writer.Close()\n\n\t// Write a simple array\n\terr = writer.WriteVariable(\u0026types.Variable{\n\t\tName:       \"A\",\n\t\tDimensions: []int{3},\n\t\tDataType:   types.Double,\n\t\tData:       []float64{1.0, 2.0, 3.0},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Write a matrix (multi-dimensional)\n\terr = writer.WriteVariable(\u0026types.Variable{\n\t\tName:       \"B\",\n\t\tDimensions: []int{2, 3},\n\t\tDataType:   types.Double,\n\t\tData:       []float64{1, 2, 3, 4, 5, 6},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// Write complex numbers\n\terr = writer.WriteVariable(\u0026types.Variable{\n\t\tName:       \"C\",\n\t\tDimensions: []int{2},\n\t\tDataType:   types.Double,\n\t\tIsComplex:  true,\n\t\tData: \u0026types.NumericArray{\n\t\t\tReal: []float64{1.0, 2.0},\n\t\t\tImag: []float64{3.0, 4.0},\n\t\t},\n\t})\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n```\n\n## Supported Features\n\n### Reader Support\n\n| Feature              | v5 (v5-v7.2) | v7.3+ (HDF5) |\n|----------------------|--------------|--------------|\n| Numeric arrays       | ✅           | ✅           |\n| Complex numbers      | ✅           | ✅           |\n| Character arrays     | ✅           | ✅           |\n| Multi-dimensional    | ✅           | ✅           |\n| Structures           | ✅           | ✅           |\n| Cell arrays          | ✅           | ✅           |\n| Sparse matrices      | ✅           | ✅           |\n| Compression          | ✅           | ✅           |\n| Function handles     | ❌ Out of scope | ❌ Out of scope |\n| Objects              | ❌ Out of scope | ❌ Out of scope |\n\n### Writer Support\n\n| Feature              | v5 (v5-v7.2) | v7.3+ (HDF5) |\n|----------------------|--------------|--------------|\n| Numeric arrays       | ✅           | ✅           |\n| Complex numbers      | ✅           | ✅           |\n| Character arrays     | ✅           | ✅           |\n| Multi-dimensional    | ✅           | ✅           |\n| Both endianness      | ✅ MI/IM     | N/A          |\n| Structures           | 📅 v0.5.0+   | 📅 v0.5.0+   |\n| Cell arrays          | 📅 v0.5.0+   | 📅 v0.5.0+   |\n| Compression          | 📅 v0.5.0+   | 📅 v0.5.0+   |\n\n## Known Limitations\n\n### Writer Limitations\n- No compression support (planned for v0.5.0+)\n- No structures/cell arrays writing (planned for v0.5.0+)\n\n### Reader Limitations\n- Function handles not supported (MATLAB-specific, cannot be serialized)\n- Objects not supported (language-specific)\n\n### What Works Well ✅\n- ✅ **v5 Writer COMPLETE** - All numeric types, complex numbers, multi-dimensional arrays\n- ✅ **v7.3 Writer COMPLETE** - Full HDF5-based writing\n- ✅ **Parser bugs FIXED** - Multi-dimensional arrays, multiple variables\n- ✅ All numeric types (double, single, int8-64, uint8-64)\n- ✅ Multi-dimensional arrays (read \u0026 write)\n- ✅ Complex numbers (proper MATLAB format for both v5 and v7.3)\n- ✅ Round-trip verified (v5 write → read, v7.3 write → read)\n- ✅ Cross-platform (Windows, Linux, macOS)\n- ✅ Both endianness (MI/IM for v5)\n\nSee [CHANGELOG.md](CHANGELOG.md) for detailed limitations and planned fixes.\n\n## Documentation\n\n- **[Getting Started](docs/)** - Basic usage examples\n- **[API Reference](https://pkg.go.dev/github.com/scigolib/matlab)** - Full API documentation\n- **[Architecture](.claude/CLAUDE.md)** - Internal architecture and design decisions\n- **[CHANGELOG.md](CHANGELOG.md)** - Version history and changes\n- **[ROADMAP.md](ROADMAP.md)** - Future plans and development timeline\n\n## Development\n\n### Requirements\n- Go 1.25 or later\n- HDF5 library (for v7.3+ support): `github.com/scigolib/hdf5` develop branch (commit 36994ac)\n- No external C dependencies\n\n### Building\n\n```bash\n# Clone repositories (side-by-side)\ncd D:\\projects\\scigolibs\ngit clone https://github.com/scigolib/hdf5.git\ngit clone https://github.com/scigolib/matlab.git\n\n# Build MATLAB library\ncd matlab\nmake build\n\n# Run tests\nmake test\n\n# Run linter\nmake lint\n\n# Generate test data\ngo run scripts/generate-testdata/main.go\n\n# Verify round-trip\ngo run scripts/verify-roundtrip/main.go\n```\n\n### Testing\n\n```bash\n# Run all tests\nmake test\n\n# Run with coverage\nmake test-coverage\n\n# Run specific tests\ngo test ./internal/v73 -v\n\n# Run linter\nmake lint\n```\n\n### Test Data\n\nThe project includes test data in `testdata/`:\n- `testdata/generated/` - Files created by our writer (8 files)\n- `testdata/scipy/` - Reference files from SciPy project (3 files)\n\n---\n\n## Contributing\n\nContributions are welcome! This is a stable project and we'd love your help.\n\n**Before contributing**:\n1. Read [CONTRIBUTING.md](CONTRIBUTING.md) - Git workflow and development guidelines\n2. Check [open issues](https://github.com/scigolib/matlab/issues)\n3. Review the architecture in `.claude/CLAUDE.md`\n\n**Ways to contribute**:\n- 🐛 Report bugs\n- 💡 Suggest features\n- 📝 Improve documentation\n- 🔧 Submit pull requests\n- ⭐ Star the project\n- 🧪 Test with real MATLAB files and report compatibility\n\n**Priority Areas**:\n- Test MATLAB/Octave compatibility with real-world files\n- Add compression support for v5/v7.3 writers\n- Implement structures and cell arrays writing\n- Improve test coverage (current: 92.8%)\n\n---\n\n## Comparison with Other Libraries\n\n| Feature | This Library | go-hdf5/* | matlab-go |\n|---------|-------------|-----------|-----------|\n| Pure Go | ✅ Yes | ❌ CGo required | ✅ Yes |\n| v5-v7.2 Read | ✅ Yes | ❌ Limited | ⚠️ Partial |\n| v7.3+ Read | ✅ Yes | ❌ No | ❌ No |\n| **Write Support** | ✅ **v5 + v7.3 Yes** | ❌ No | ❌ No |\n| Complex Numbers | ✅ Yes | ⚠️ Limited | ❌ No |\n| Maintained | ✅ Active | ❌ Inactive | ❌ Inactive |\n| Cross-platform | ✅ Yes | ⚠️ Platform-specific | ✅ Yes |\n\n---\n\n## Related Projects\n\n- **[HDF5 Go Library](https://github.com/scigolib/hdf5)** - Pure Go HDF5 implementation (used for v7.3+ support)\n- Part of [SciGoLib](https://github.com/scigolib) - Scientific computing libraries for Go\n\n---\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n\n- The MathWorks for the MATLAB file format specification\n- The HDF Group for HDF5 format specification\n- [scigolib/hdf5](https://github.com/scigolib/hdf5) for HDF5 support\n- SciPy project for reference test data\n- All contributors to this project\n\n---\n\n## Support\n\n- 📖 Documentation - See `.claude/CLAUDE.md` for architecture details\n- 🐛 [Issue Tracker](https://github.com/scigolib/matlab/issues)\n- 💬 Discussions - GitHub Discussions (coming soon)\n- 📧 Contact - Via GitHub Issues\n\n---\n\n**Status**: ✅ **STABLE** - Production-ready read and write support for both v5 and v7.3 formats!\n**Last Updated**: 2026-03-30\n\n**Ready for**: Production use, testing, feedback, and real-world usage\n**Stable API**: Minor API changes may occur in 0.x versions, major stability expected\n\n---\n\n*Built with ❤️ by the SciGoLib community*\n","funding_links":[],"categories":["Science and Data Analysis"],"sub_categories":["HTTP Clients"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscigolib%2Fmatlab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscigolib%2Fmatlab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscigolib%2Fmatlab/lists"}