In MatLab say you do:
E = cell(3,1);
How do I know whether E is being used already and the call above doesn’t override it? Do I have to run the program and break at that point? Is there a method in the interpreter which will do this for me? For instance, in C++, the compiler will tell you if you try to use an existing name.
In order to use exist, you must run the script first so the workspace will be populated with all the variables you are using. If you want to check and see if a variable name is free when you’re writing the script, my favorite way to check is to use the tab key in the Matlab IDE. It will bring up all the auto-complete options. If you’ve previously defined a variable names “E” in your script or function, typing “E” should show E as an option and alert you not to use that variable.
Also, the latest version of the IDE introduced automatic highlighting of all uses of a given variable in a script. Just put the cursor in between the letters or at the end of the variable name. It’s quite handy to visually inspect all uses of a variable name in your script.