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
>>
>
>

Reply via email to