Compose-2025: Cells and Structs in OML
- Create a cell.
- Modify element in a cell.
- Create a struct.
- Modify a struct.
- Convert a struct to cell.
- Convert a cell to struct.
Creating a Cell
Modifying an Element in a Cell
Create a Struct
Modify a Sruct
Convert a Struct to a Cell
struct2cell
. The original struct’s fields change to
the number index, as shown
below:student.name = 'Bob';
student.age = 18;
student.id = 8015
% transfer a struct to a cell
struct2cell(student)
This returns:
Convert a Cell to Struct
Cell = {'Bob','Lily','Emma';20,18,25;8051,8052,8053};
Fields = {'name','age','id'};
Struct = cell2struct(Cell,Fields)
This script converts a cell to a struct with the fields name, age, and id respectively:
Click +
in front of Struct in the Variable Browser to expand this struct. The Variable Browser displays this: