Serialize/Deseriali​ze

Encode and decode almost any matlab variable into a sequence of bytes.

您现在正在关注此提交

This pair of functions can serialize and deserialize (i.e. encode and decode) almost any matlab object into a sequence of bytes. This will be useful for saving objects to disk, sending them over the network, or perhaps to other programs.

Any combination of structs, cells and matrices are supported. All the data types (i.e. all integer sizes, chars, bools, singles and doubles) are supported. They are automatically converted back to double on decoding, but you can easily change this.

I haven't tested it extensively, but it's quite short so any bugs should be easy to fix.

Usage is like this:

astruct.field1 = [1 2 3]; astruct.field2 = {'foo', 'bar', 'baz'};
serialized_astruct = serialize(astruct);
deserialized_astruct = deserialize(serialized_astruct);

After execution, astruct and deserialized_astruct should be equal.

引用格式

Tim (2026). Serialize/Deserialize (https://ww2.mathworks.cn/matlabcentral/fileexchange/29457-serialize-deserialize), MATLAB Central File Exchange. 检索时间: .

致谢

参考作品: serialize

启发作品: DataHash, Fast serialize/deserialize

类别

Help CenterMATLAB Answers 中查找有关 Data Type Conversion 的更多信息

一般信息

MATLAB 版本兼容性

  • 兼容任何版本

平台兼容性

  • Windows
  • macOS
  • Linux
版本 已发布 发行说明 Action
1.1.0.0

Fix bug with single numbers.

1.0.0.0