Matlab YAML

This package contains Matlab class to serialize/decode matlab object in YAML format. The software internally uses SnakeYAML java class to convert yaml to java object and then translates it into Matlab object.

Download

yaml.tgz

Install

Decompress yaml.tgz. Add path to the directory containing YAML.m.

Usage

To serialize matlab object:

  >> X = struct('field1', rand(3,2), 'field2', 'hello');
  >> S = YAML.dump(X);
  >> disp(S);
  field1:
  - [0.9571669482429456, 0.14188633862721534]
  - [0.4853756487228412, 0.421761282626275]
  - [0.8002804688888001, 0.9157355251890671]
  field2: hello

To decode yaml string:

  >> X = YAML.load(S);
  >> disp(X)
    field1: [3x2 double]
    field2: 'hello'

The YAML class also has convenient YAML.read(filepath) and YAML.write(filepath,X) methods to directly import from/export to a file.

  YAML.write('/path/to/your.yml', X); % save X to a yaml file
  X = YAML.read('/path/to/your.yml'); % load X from a yaml file

Check help YAML for detail.

Note: If you are looking for how to read OpenCV YAML files, check cv.FileStorage function in mexopencv.