Stuart’s MATLAB Videos

Watch and Learn

Advanced MATLAB: Dynamic field names

We have MATLAB users come into The MathWorks to present their work in MATLAB from time to time. Recently there was an interesting presentation with some really great “Clutter classification” algorithms in a GUI. One of the questions that came out of that discussion was how to get rid of a bunch of EVAL statements from their code. The following code shows how they can be avoided using “dot parens notation”, or Dynamic Field Names as they are formally known. a.doug = ‘Hull’ a.jiro = ‘Doke’ name = ‘doug’; last = a.doug eval([‘last = a.’ name]) %BAD last = a.(name) %GOOD
Video Player is loading.
Current Time 0:00
Duration 1:59
Loaded: 0.00%
Stream Type LIVE
Remaining Time 1:59
 
1x
  • Chapters
  • descriptions off, selected
  • captions off, selected
  • en (Main), selected
     
    |
    • print

    Comments

    To leave a comment, please click here to sign in to your MathWorks Account or create a new one.

    Loading...
    Go to top of page