๐ MATLAB File Reader/Writer v0.1.1-beta - Complex Number Format Fix
Pre-releasePure Go library for reading and writing MATLAB
.matfiles
Part of the SciGoLib ecosystem - scientific computing libraries for Go
๐ What's Fixed
Complex Number Format โจ MAJOR FIX
-
โ Proper MATLAB v7.3 complex format - Complex numbers now use standard MATLAB structure
- Before (v0.1.0-beta): Flat workaround (
varname_real,varname_imagdatasets) - After (v0.1.1-beta): Proper group structure (
/varnamegroup with/real,/imagnested datasets) - Group attributes:
MATLAB_classandMATLAB_complexfor full compatibility
- Before (v0.1.0-beta): Flat workaround (
-
โ Full MATLAB/Octave compatibility - Files with complex numbers now fully compatible!
-
โ HDF5 dependency updated to develop branch (commit 36994ac):
- Nested datasets support
- Group attributes support
- New
CreateGroup()API returning(*GroupWriter, error)
Race Detector Fix
- โ
Race detector now works on Gentoo WSL2
- Issue: "hole in findfunctab" error (Gentoo build configuration)
- Solution: Added
-ldflags '-linkmode=external'to force external linking - Not a Go bug - distribution-specific issue resolved
Quality Improvements
-
โ 3 new comprehensive tests for complex numbers:
TestWriteVariable_ComplexSupported- Basic complex writeTestWriteVariable_ComplexFormat- Structure validationTestWriteVariable_ComplexInvalidData- Error handling (table-driven)
-
โ Documentation cleanup:
- Removed obsolete TODO comments
- Added descriptive comments for complex handling
- Updated all version references
๐ Quality Metrics
- Tests: 30 total, 27 passing (90%) - up from 88.9%
- Race detector: 0 races detected โ
- Linter: 0 errors, 0 warnings โ
- CI: All platforms green (Linux, macOS, Windows) โ
๐ฆ Installation
go get github.com/scigolib/[email protected]๐ง What Changed (Breaking)
HDF5 API Update
If you're using the HDF5 library directly, note the API change:
// OLD (v0.11.4-beta):
err := fw.CreateGroup("/path")
// NEW (develop branch):
group, err := fw.CreateGroup("/path")
group.WriteAttribute("MATLAB_class", "double")
group.WriteAttribute("MATLAB_complex", uint8(1))This change enables proper MATLAB complex format!
๐ก Example: Writing Complex Numbers
package main
import (
"log"
"github.com/scigolib/matlab"
"github.com/scigolib/matlab/types"
)
func main() {
// Create MATLAB v7.3 file
writer, err := matlab.Create("complex_example.mat", matlab.Version73)
if err != nil {
log.Fatal(err)
}
defer writer.Close()
// Create complex array: z = [1+0.5i, 2+1.5i, 3+2.5i]
variable := &types.Variable{
Name: "z",
DataType: types.Double,
Dimensions: []int{3},
IsComplex: true,
Data: &types.NumericArray{
Real: []float64{1.0, 2.0, 3.0},
Imag: []float64{0.5, 1.5, 2.5},
Dimensions: []int{3},
Type: types.Double,
},
}
// Write variable
if err := writer.WriteVariable(variable); err != nil {
log.Fatal(err)
}
// โ
File is now fully compatible with MATLAB/Octave!
}HDF5 Structure (proper MATLAB format):
/z (group)
- Attributes: MATLAB_class='double', MATLAB_complex=1
/real (dataset: [1.0, 2.0, 3.0])
/imag (dataset: [0.5, 1.5, 2.5])
๐ What's Different from v0.1.0-beta
| Aspect | v0.1.0-beta | v0.1.1-beta |
|---|---|---|
| Complex Format | Flat workaround | โ Proper MATLAB structure |
| MATLAB/Octave Compatible | โ Full compatibility | |
| Race Detector | โ Works with external linking | |
| HDF5 Dependency | v0.11.4-beta | develop (commit 36994ac) |
| Tests | 27 tests (88.9%) | 30 tests (90%) |
| Complex Tests | Basic only | 3 comprehensive test cases |
โ ๏ธ Known Limitations (Still Beta)
Reader Limitations
โ ๏ธ 3 tests still skipped due to bugs with multi-dimensional arrays and multiple variablesโ ๏ธ Structures/cell arrays: partial support only
Writer Limitations
- โ v5 Writer not implemented - only v7.3 format supported (coming in v0.2.0)
- โ No compression support yet
- โ No structures/cell arrays writing yet
What Works โ
- โ All numeric types (double, single, int8-64, uint8-64)
- โ Multi-dimensional arrays
- โ Complex numbers (proper MATLAB v7.3 format) โจ FIXED!
- โ Round-trip write โ read verified
- โ Full MATLAB/Octave compatibility
- โ Cross-platform (Windows, Linux, macOS)
๐ Documentation
- README.md - Project overview and quick start
- ROADMAP.md - Development plan and feature timeline
- CHANGELOG.md - Detailed release history
- CONTRIBUTING.md - How to contribute
๐ฎ What's Next
v0.2.0 (3-4 weeks)
- โญ v5 Writer implementation (TASK-011)
- โญ Fix reader bugs (multi-dim arrays, multiple variables)
- โญ Improve test coverage (target: 80%+)
v0.3.0+ (Future)
- Functional Options Pattern (flexible API)
- Context Support (cancellable operations)
- Compression support
- Full structures/cell arrays support
v1.0.0 (2026)
- Production stable release
- API freeze and long-term support
- Community feedback incorporated
๐ค Contributing
We welcome contributions! Please read CONTRIBUTING.md for guidelines.
Priority areas:
- Test coverage improvements
- Bug fixes for reader issues
- v5 writer implementation
- Real-world MATLAB file testing
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
๐ Dependencies
- github.com/scigolib/hdf5 develop branch (commit 36994ac)
- Updated from v0.11.4-beta for nested datasets and group attributes support
๐ License
MIT License - See LICENSE file for details
Full Changelog: https://github.com/scigolib/matlab/blob/main/CHANGELOG.md
๐ค Released 2025-11-03: Proper MATLAB complex format + race detector fix