yida / msgpack-matlab

MessagePack for Matlab
Apache License 2.0
8 stars 7 forks source link

Does not preserve multidimensional array shape #2

Open djoshea opened 10 years ago

djoshea commented 10 years ago

Hi there, really nice work! One limitation of this approach is that it does not preserve the shape of the array (i.e. the size along each dimension). I wonder if you've considered adding this functionality? If not, it's something I might work on. One way to go about this is to store each value as a map containing a fields 'shape' and 'value'. This is I think the approach taken by msgpack-numpy here [ https://github.com/lebedov/msgpack-numpy/blob/master/msgpack_numpy.py ]. Do you have any thoughts on this or would you recommend a different approach?

jerlich commented 8 years ago

@djoshea are you using this code? Did you make the change to preserve matrix shape?

djoshea commented 8 years ago

Hey Jeff, No I didn't. The numpy approach seems like it replaces each numpy array with a dict that has the size, the element type, and the data.

I ended up using a simpler, homebrewed serialization format since everything we were sending to our data logger was a Matlab matrix or a string. The serialization happens in Simulink Real-Time and only adds a few extra bytes over the raw data. The upside is that it was easy. The downside is it's homebrewed.

If you just want serialization and don't care about it being Matlab specific, this might be useful http://undocumentedmatlab.com/blog/serializing-deserializing-matlab-data

djoshea commented 8 years ago

Actually, using UBJSON looks promising since it's simple, and then jsonlab already supports this in Matlab, as far as I can tell. http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/Examples#MATLAB_array_demo

jerlich commented 8 years ago

We looked into ubjson but I think we had problems reading it in Python on the other side.

I'll take another look. My problem with json lab is that it is written in matlab and very slow.

Sent from my iPhone

On Jun 30, 2016, at 03:37, djoshea notifications@github.com wrote:

Actually, using UBJSON looks promising since it's simple, and then jsonlab already supports this in Matlab, as far as I can tell. http://iso2mesh.sourceforge.net/cgi-bin/index.cgi?jsonlab/Doc/Examples#MATLAB_array_demo

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.