Hi Tim, thanks for the reply, it turned out that not MAT/HDF5 was at fault, but my code that did the array-of-objects to struct-of-arrays (or rather dict-of-arrays) conversion, as the former is incredibly wasteful and hard to deal with in Matlab. For some reason, the way I dynamically created new arrays didn't propagate the field types of the structs properly, and all numeric fields ended up as Float64 instead of their proper types, which is surprising, as normally Julia warns about type conversions that could incur data loss.
Cheers! On 12 April 2016 at 20:37, Tim Holy <[email protected]> wrote: > I'm not quite following, are these changes to MAT or to how you call MAT? > If > the former, can you submit the changes to MAT as a pull request? See > http://docs.julialang.org/en/stable/manual/packages/#package-development > > If you can't, let us know and maybe someone else will do it. > > Best, > --Tim > > On Tuesday, April 12, 2016 09:36:52 AM Dömötör Gulyás wrote: > > Alright, while the previous code didn't properly propagate data types for > > some reason, this does: > > obj = objects[1] > > fieldNames = fieldnames(objects[1]) > > typeDict = mapreduce(name -> Dict(string(name) => typeof(obj.(name))), > > merge, fieldNames) > > outDict = Dict(map(fieldType -> (fieldType[1],Array{fieldType[2],1}()), > > typeDict)) > > > > And thus all is well in the .mat file, no longer is everything Float64, > but > > of the proper data types. > > > > Cheers! > > > > On Tuesday, April 12, 2016 at 5:25:23 PM UTC+2, Dömötör Gulyás wrote: > > > I've apparently made some progress... the following code: > > > outDict = mapreduce(name -> Dict(string(name) => > > > > > > Array{typeof(obj.(name)), 1}()), merge, fieldNames) > > > produced all Array{Float64,1} arrays, and I'm still trying to figure > out > > > why, as > > > > > > typeDict = mapreduce(name -> Dict(string(name) => > typeof(obj.(name))), > > > > > > merge, fieldNames) > > > > > > -> typeDict = > > > > > > > Dict("msgid"=>UInt32,"data"=>UInt64,"bufsize"=>UInt32,"timestamp"=>Float64 > > > ) > > > shows the correct types. > > > > > > On 12 April 2016 at 16:03, Dömötör Gulyás wrote: > > >> Hi, > > >> > > >> in an attempt to export some data to Matlab that's an 'uint64' array, > I > > >> discovered that apparently all arrays are written out as 'double', > thus > > >> mangling my data. Is there a way to get the MAT package to respect > data > > >> types when writing the .mat files? As an aside, I checked that reading > > >> back > > >> the .mat data in julia is mangled, thus confirming that it's not just > > >> Matlab having a fit. > > >> > > >> Thanks, > > >> Dömötör > >
