yaml.dumpFile()¶
dumpFile(filePath, data, style)¶
Serialize MATLAB data to a YAML file.
yaml.dumpFile(filePath, data)serializes MATLAB variabledatato a YAML document and writes it to the file specified byfilePath.yaml.dumpFile(filePath, data, style)specifies the YAML formatting style.
Parameters¶
filePath (
string) – Path of the YAML file to write. Parent directories are created automatically if they do not exist.data (
any) – The MATLAB variable to be serialized.style (
{'auto', 'block', 'flow'},default='auto') – Output style for YAML sequences and mappings:'auto': Automatically choose best fit.'block': Human-readable multi-line (standard YAML).'flow': Compact inline style (JSON-like).
MATLAB-YAML data conversion¶
The following MATLAB types are supported and mapped to YAML types:
MATLAB type |
YAML type |
|---|---|
1D cell array |
Sequence |
1D non-scalar array |
Sequence |
2D/3D cell array |
Nested sequences |
2D/3D non-scalar array |
Nested sequences |
struct |
Mapping |
scalar single/double |
Floating-point number |
scalar int8/../int64 |
Integer |
scalar uint8/../uint64 |
Integer |
scalar logical |
Boolean |
scalar string |
String |
char vector |
String |
any 0-by-0 value |
null |
Array conversion can be ambiguous. To ensure consistent conversion behaviour, consider manually converting array data to nested 1D cells before converting it to YAML.
Examples¶
>> data.a = 1;
>> data.b = {"text", false};
>> yaml.dumpFile("test.yaml", data);
See also