eval
. This prevents
Furthermore, concatenated character vectors within an eval
statement are often difficult to read. This makes code less clear and causes
issues with sharing and maintaining code.
Structure fields or object properties can be accessed using dynamic field names. The example shows how code
using eval
to assign numbered field names can be refactored
to use dynamic field names.
Old | New |
---|---|
for i = 1:5
|
for i = 1:5
|
handles
will
be accessed and this allows performance optimization.
For more information, see Generate Field Names from Variables .