JuliaIO / MAT.jl

Julia module for reading MATLAB files
MIT License
278 stars 71 forks source link

Trying to save variable throws: LoadError: This is the write function for CompositeKind, but the input doesn't fit #50

Closed aramirezreyes closed 8 years ago

aramirezreyes commented 8 years ago

Hi! Trying to save a variable to a .MAT file with julia 0.4.2 throws:

ERROR: LoadError: This is the write function for CompositeKind, but the input doesn't fit
 in m_write at /home/argel/.julia/v0.4/MAT/src/MAT_HDF5.jl:485
 in write at /home/argel/.julia/v0.4/MAT/src/MAT_HDF5.jl:494
 [inlined code] from /media/argel/ARR_ECAIM/2016/Cortes_horizontales_Presion_mod2.jl:97
 in anonymous at no file:0
 in include at ./boot.jl:261
 in include_from_node1 at ./loading.jl:304
 in process_options at ./client.jl:280
 in _start at ./client.jl:378
while loading /media/argel/ARR_ECAIM/2016/Cortes_horizontales_Presion_mod2.jl, in expression starting on line 8

The variable is defined by Alturas = 2000: 100:5000

And im trying to save it as: filep = matopen(string(Ruta2,"P_4Dn",archi,".mat"),"w"); write(filep,"Alturas",Alturas); close(filep);

I believe is a bug.

I wish i could be of more help!

simonster commented 8 years ago

2000:100:5000 is a StepRange{Int,Int}, which is not a type supported by MATLAB. Use collect(Alturas) to convert it to a vector.

aramirezreyes commented 8 years ago

Damn! Thanks a lot for the support! i should've noticed... Sorry!

BambOoxX commented 3 years ago

@simonster I just had the same issue. Of course, I stumbled upon this page, so the problem was solved quite easily, but do you think it could help users to have either a more explicit error message or (maybe too aggressive) an automatic conversion to vector of such range objects ?

iuliancioarca commented 2 years ago

I experienced something similar while saving a dict containing ascii char. Background: first saved a .mat file with a field containing the string "s". Somehow, when reading it back, it was read as ascii char 's'. Saving again on disk failed with the mentioned error.