I am designing an application that needs to start with no variables at all. But then, at some point, the user will input what he wants to count, say, oranges. Then he will type “oranges”. After he writes oranges, I want Matlab to create a variable “orangesCounter”. Does anyone have an idea how I can achieve this?
Or maybe someone knows the name for what I am trying to do, if it has a specific name. I just don’t know how to properly Google this question since I do not know if there is a name for this type of variable creation.
Thanks!
You’re setting yourself up for a huge mess, because how are you going to handle variables with names that aren’t known to you in your code? Anyway, it’s your foot, so here’s the gun:
Here’s a better way to do this:
Note the index – you can have multiple name/value pairs in the structure.