serialize

Create matlab code from a variable

您现在正在关注此提交

matcode = SERIALIZE(x) generates matlab code of x
matcode = SERIALIZE(x, n) generates matlab code of x retaining n digits
of precision

SERIALIZE should be able to create matlab code of the following data types:
- matrices, vectors, and scalars of any class and dimension
- strings
- structs, arrays of structs with up to six dimensions
- cell arrays
- matlab objects with a copy constructor implemented
- empty values of any class
- any combinations hereof

The value of x can be obtained by
eval(matcode)

Examples
x = [1 2 3; 3 4 5];
serialize(x)

x = uint8(rand(10)*5);
matcode = serialize(x)

x = {rand(3,3,3,4), 'a string value', {1 2 3; 1 3 3 }}
matcode = serialize(x, 30)

引用格式

Jøger Hansegård (2026). serialize (https://ww2.mathworks.cn/matlabcentral/fileexchange/12063-serialize), MATLAB Central File Exchange. 检索时间: .

致谢

启发作品: Serialize/Deserialize

类别

Help CenterMATLAB Answers 中查找有关 Programming 的更多信息

一般信息

MATLAB 版本兼容性

  • 兼容任何版本

平台兼容性

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

Fixed bug when serializing strings with special characters