List variables in m-file
2 ビュー (過去 30 日間)
古いコメントを表示
I would like to rename some variables in an m-file, and would like to automate this process. I have tried using regexprep, but ran into some problems. I noticed a feature in the newest versions of Matlab, where you can automatically rename variables. Is there a command line version of this functionality. Alternatively, what would be the best way of renaming the variables, without having to run the file?
2 件のコメント
Cedric
2013 年 4 月 25 日
Do you know the name of these variables a priori, or is it something that has to be detected by the program?
採用された回答
Walter Roberson
2013 年 4 月 24 日
Example of replacing a variable in a string:
S = 'x^2 + 3*x*y + x1/x';
regexprep(S, '(?<![A-Za-z0-9_])x(?![A-Za-z0-9_])', 'YO')
3 件のコメント
Walter Roberson
2013 年 4 月 25 日
\w would likely be a good idea. I was thinking at the time that it matched a slightly different set of characters than was needed for MATLAB identifiers, but you are right that it is the same.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!