I can’t seem to find any standard functions for serializing data. I have a large 128×51 array that I need need to store in a single database field. Without some kind of serializing, things will be problematic.
Whats the best way to solve this? I don’t use matlab quite that much so I’m not familiar with standard procedures…
One possibility is to use the TYPECAST function to convert numeric values into UINT8 bytes (only works for full, non-complex numeric values).
Note that the matrix has to be reshaped into a vector prior to serialization, thus its size will also have to be separately stored (or even serialized using the same process):
Now you can store
bandb_szinto the database as sequences of bytes (integers in the range[0,255])Next, when you retrieve those values from DB, you can convert them back to double values using the inverse procedure, and reshape the matrix to its original size:
Optionally, if your database does not support array types, you can just convert the byte sequence as string, and store it in a VARCHAR type of field: