Simulink Structures
Nessuna licenza
There are two m-files: struct_to_vector and vector_to_struct.
The m-file 'struct_to_vector'turns a structure into a mx1 vector. The function 'vector_to_struct' recovers the original structure. As simulink allows user defined m-funcitons to pass vectors, you could call struct_to_vector as the last line in one m-file to pass a vector (instead of the structure), and then call vector_to_struct as the first thing in another m-file to reconstruct the original structure.
The current version supports structures (1x1, with an arbitrary number of fields) made up of numeric arrays (arbitrary dimensions), strings, cells (arbitrary dimensions), and other structures (1x1, arbitrary number of fields). Cells may contain other cells, structures(1x1), arrays and strings, and so on.
The only limitations I am aware of is that it doesn't support structures of dimension higher then 1x1 (e.g. you can have an arbitrary number of fields, but any structure, to include structures contained within structures can't be more then 1x1 in size). However, matlab requires all the field names of each structure in an array of structures to be the same. A workaround to this would be to use a cell of structures, which would arguably be more generic (since it wouldn't force the fields to the the same.) Also, you cannot have
a column vector of strings. However, matlab requires that each string in a column vector have the same length, so this is of limited use. You can use a cell of strings.
Cita come
Eric Olsen (2025). Simulink Structures (https://it.mathworks.com/matlabcentral/fileexchange/2546-simulink-structures), MATLAB Central File Exchange. Recuperato .
Compatibilità della release di MATLAB
Compatibilità della piattaforma
Windows macOS LinuxTag
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Scopri Live Editor
Crea script con codice, output e testo formattato in un unico documento eseguibile.
| Versione | Pubblicato | Note della release | |
|---|---|---|---|
| 1.0.0.0 |
