Stuart’s MATLAB Videos

Watch and Learn

Refactor code to rename variable with with MATLAB editor 2

Posted by Doug Hull,

As code matures, very often the nature of variables becomes better understood and the names of the variables need to change to reflect that better understanding. This short video shows how the MATLAB editor can quickly rename a variable throughout your code.

2 CommentsOldest to Newest

Julian replied on : 1 of 2
I agree, this is a neat feature, and I am very pleased we upgraded to a version that supports it. Another gotcha though is that there is no warning if you are already using the new name for some other variable, and undo might not rewind this op. If you rename from y to x, say, then realise you already had another use of x, you need to go through each line to figure out which x is which... Of course, sometimes you may deliberately choose a variable name already in use. This feature could be improved even more by better Undo-ability and a warning if you choose an identifier in use elsewhere.
Joshua replied on : 2 of 2
I am eagerly awaiting for the day when Matlab has true refactoring support, similar to Netbeans. For example, it would be nice if the single file name change refactoring could be applied to all of the files in a @Class folder. That would save me a lot of time and effort. Even the ability to automatically search through multiple files for a variable or function call would be helpful.