Recurses through directories, finding Matlab code and replacing LHS tildes with 'ans' to make code backwards compatible.
WARNING: this overwrites files!!! Copy the whole folder before use!!!
Please report bugs on the Matlab FX.
And if you can come up with a better regex let me know.
I am currently rating this as one star because it should not overwrite files by default! This is potentially very dangerous.
You should copy the directory, and make the changes in the copied files. If this is implemented, I will reconsider my rating. The idea is fine btw ...
I recommend not to overwrite the automatically accessed "ans" variable. This can be confusing e.g. during debugging. I'd use something like "dummy" instead.
The function is useful to support Matlab versions <= 2009a. The help text does niot have a H1-line, but is clear and contains the required warning. Perhaps a dialog might be added to ask for a confirmation. I cannot test the robustness of the REGEXP currently, such that I do not dare to rate this submission yet.
Btw. the need to include a subfunction to obtain a recursive list of files in subfolders is shows, that TMW should urgently include this as a toolbox function. This is a standard task which should not be left to the users.
Added warning dialogue at top of function. And explicitly declared DUMMY_VAR_NAME for user to change at his/her discretion.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.