st = struct()
st = struct([])
st = struct(object)
st = struct(field, value)
st = struct(field, value, field2, value2, ..., fieldn, valuen)
| Parameter | Description |
|---|---|
| field, field2, ... , fieldn | strings: field names. Valid names follow variable identifier rules. |
| value, value2, ..., valuen | values of any Nelson type |
| object | an old-style object or a classdef object |
| Parameter | Description |
|---|---|
| st | a structure |
struct creates a structure from field/value pairs.
struct(object) converts an object to a structure containing its public fields or public classdef properties.
For classdef handle objects, struct reads the current public property values from the handle object.
date_st = struct('day', 15, 'month', 'August', 'year', 1974)
clear classes
d = [tempdir(), 'nelson_help_struct/'];
mkdir(d);
filewrite([d, '/NelsonHelpStructPoint.m'], ["classdef NelsonHelpStructPoint"; " properties"; " X = 0"; " Y = 0"; " end"; "end"]);
addpath(d);
obj = NelsonHelpStructPoint();
obj.X = 3;
obj.Y = 4;
st = struct(obj)
| Version | Description |
|---|---|
| 1.0.0 | initial version |
| 1.3.0 | Scalar string allowed as field name. |
| 2.0.0 | classdef object conversion documented |