I have an existing structure array which is loaded into the workspace with a load()
statement. The fields contain char
and double
.
I want to create this structure, including the contents of its fields, in a script instead, but as the structure is large, I don't want to write all the fields and values out by hand.
Dragging the structure fields from the workspace into the editor just copies the field names over.
Is there an easy and convenient way to extract the fields and their values, so that the fields of the structure array
example_struct
are turned into statements of the form
example_struct.field1 = <some_value>;
which doesn't involve writing a script?
EDIT: I want to write a script (an M-file) which populates a new structure array with actual values. I want to get the statements for that script, including the values, out of an existing structure which I have loaded with load()
, but I want to know if that can be done without writing a script (say, using fprintf statements) to perform the task.