@@ -21,8 +21,8 @@ A modern, pure Go library for **reading and writing** MATLAB `.mat` files withou
2121✨ ** Read & Write Support**
2222- 📖 Read MATLAB v5-v7.2 files (traditional format)
2323- 📖 Read MATLAB v7.3+ files (HDF5 format)
24- - ✍️ ** Write MATLAB v7.3+ files** (HDF5 format) - NEW!
25- - ✍️ Write v5 format (coming in v0.2.0)
24+ - ✍️ ** Write MATLAB v7.3+ files** (HDF5 format)
25+ - ✍️ ** Write MATLAB v5-v7.2 files ** (traditional format) - ** NEW in v0.2.0! **
2626
2727🎯 ** Key Capabilities**
2828- Simple, intuitive API
@@ -88,6 +88,8 @@ func main() {
8888
8989### Writing MAT-Files
9090
91+ #### v7.3 Format (HDF5-based)
92+
9193``` go
9294package main
9395
@@ -134,6 +136,65 @@ func main() {
134136}
135137```
136138
139+ #### v5 Format (Traditional Binary) - ** NEW in v0.2.0!**
140+
141+ ``` go
142+ package main
143+
144+ import (
145+ " log"
146+
147+ " github.com/scigolib/matlab"
148+ " github.com/scigolib/matlab/types"
149+ )
150+
151+ func main () {
152+ // Create new MAT-file (v5 format - legacy compatible)
153+ writer , err := matlab.Create (" output_v5.mat" , matlab.Version5 )
154+ if err != nil {
155+ log.Fatal (err)
156+ }
157+ defer writer.Close ()
158+
159+ // Write a simple array
160+ err = writer.WriteVariable (&types.Variable {
161+ Name: " A" ,
162+ Dimensions: []int {3 },
163+ DataType: types.Double ,
164+ Data: []float64 {1.0 , 2.0 , 3.0 },
165+ })
166+ if err != nil {
167+ log.Fatal (err)
168+ }
169+
170+ // Write a matrix (multi-dimensional)
171+ err = writer.WriteVariable (&types.Variable {
172+ Name: " B" ,
173+ Dimensions: []int {2 , 3 },
174+ DataType: types.Double ,
175+ Data: []float64 {1 , 2 , 3 , 4 , 5 , 6 },
176+ })
177+ if err != nil {
178+ log.Fatal (err)
179+ }
180+
181+ // Write complex numbers
182+ err = writer.WriteVariable (&types.Variable {
183+ Name: " C" ,
184+ Dimensions: []int {2 },
185+ DataType: types.Double ,
186+ IsComplex: true ,
187+ Data: &types.NumericArray {
188+ Real: []float64 {1.0 , 2.0 },
189+ Imag: []float64 {3.0 , 4.0 },
190+ },
191+ })
192+ if err != nil {
193+ log.Fatal (err)
194+ }
195+ }
196+ ```
197+
137198## Supported Features
138199
139200### Reader Support
@@ -151,36 +212,40 @@ func main() {
151212| Function handles | ❌ | ❌ |
152213| Objects | ❌ | ❌ |
153214
154- ### Writer Support (v0.1.1-beta )
215+ ### Writer Support (v0.2.0 )
155216
156217| Feature | v5 (v5-v7.2) | v7.3+ (HDF5) |
157218| ----------------------| --------------| --------------|
158- | Numeric arrays | 📋 Planned | ✅ |
159- | Complex numbers | 📋 Planned | ✅* |
160- | Character arrays | 📋 Planned | ✅ |
161- | Multi-dimensional | 📋 Planned | ✅ |
219+ | Numeric arrays | ✅ | ✅ |
220+ | Complex numbers | ✅ | ✅ |
221+ | Character arrays | ⚠️ Partial | ✅ |
222+ | Multi-dimensional | ✅ | ✅ |
223+ | Both endianness | ✅ MI/IM | N/A |
162224| Structures | ❌ Future | ❌ Future |
163225| Cell arrays | ❌ Future | ❌ Future |
164226| Compression | ❌ Future | ❌ Future |
165227
166- ## Known Limitations (v0.1.1 -beta)
228+ ## Known Limitations (v0.2.0 -beta)
167229
168230### Writer Limitations
169- - ** v5 format writing not yet implemented** (coming in v0.2.0)
170231- No compression support yet
171232- No structures/cell arrays writing yet
233+ - Character arrays (partial support for v5 Writer)
172234
173- ### Reader Issues
174- - Some bugs with multi-dimensional arrays (being fixed)
235+ ### Reader Limitations
175236- Limited support for structures and cell arrays
176- - Multiple variables in one file may have issues
237+ - No compression support
177238
178239### What Works Well ✅
179- - All numeric types (double, single, int8-64, uint8-64)
180- - Multi-dimensional arrays (write)
181- - ** Complex numbers** (proper MATLAB v7.3 format) ✨ FIXED in v0.1.1-beta
182- - Round-trip write → read verified
183- - Cross-platform (Windows, Linux, macOS)
240+ - ✅ ** v5 Writer COMPLETE** - All numeric types, complex numbers, multi-dimensional arrays ✨ NEW in v0.2.0-beta
241+ - ✅ ** v7.3 Writer COMPLETE** - Full HDF5-based writing
242+ - ✅ ** Parser bugs FIXED** - Multi-dimensional arrays, multiple variables ✨ FIXED in v0.2.0-beta
243+ - ✅ All numeric types (double, single, int8-64, uint8-64)
244+ - ✅ Multi-dimensional arrays (read & write)
245+ - ✅ Complex numbers (proper MATLAB format for both v5 and v7.3)
246+ - ✅ Round-trip verified (v5 write → read, v7.3 write → read)
247+ - ✅ Cross-platform (Windows, Linux, macOS)
248+ - ✅ Both endianness (MI/IM for v5)
184249
185250See [ CHANGELOG.md] ( CHANGELOG.md ) for detailed limitations and planned fixes.
186251
@@ -319,9 +384,9 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
319384
320385---
321386
322- ** Status** : Beta - Read and Write support for v7.3 format (proper complex numbers!)
323- ** Version** : v0.1.1 -beta
324- ** Last Updated** : 2025-11-03
387+ ** Status** : Beta - Read and Write support for both v5 and v7.3 formats!
388+ ** Version** : v0.2.0 -beta
389+ ** Last Updated** : 2025-11-06
325390
326391** Ready for** : Testing, feedback, and real-world usage
327392** Not ready for** : Production use (API may change)
0 commit comments