editor functionality: check that variable name isn't already a MATLAB function name or keyword?
古いコメントを表示
Is it possible that the editor checks automatically in the background, while I am typing, that a by me used variable or handle, etc. name isn´t already exisitent somewhere in MATLAB or a MATLAB toolbox as a function name, keyword or any other import and thus better to reserve than overwrite word? At the moment I am working without toolboxes, but I would like to be prepared as good as possible for the future, and if the editor would not check only against installed functions, but would have a list with generally from The Mathworks available functions, it could be helpful if ALL those existent words become accordingly colored. Furthermore, do the function names from my own code become automatically incorporated in the 'reserved / occupied' name list of the editor (R2013b) for color coding, if my m-files are on a reachable path?
採用された回答
その他の回答 (1 件)
Star Strider
2014 年 2 月 27 日
編集済み: Star Strider
2014 年 2 月 27 日
0 投票
One way (the method I use) is to type the name into the EDITOR window, put the mouse cursor on the word. Then either:
- right click on it to bring up a pop-up menu, then left click on Help on selection F1
- press the fn+f1 keys
Both of these bring up the documentation on the word you want information about. If it comes up ‘empty’ — there’s no documentation available on it — then it’s not a MATLAB function or reserved word.
I use this most often to bring up documentation on functions I want information about, but it also works to be sure new variable or function names aren’t already claimed. (It also brings up information on functions I write, a reason to document them with comments just below the function line.)
The iskeyword function also works, but you have to type and run this in the Command Window. (I don’t use this much because it clutters the Command Window.)
3 件のコメント
Sean de Wolski
2014 年 2 月 27 日
iskeyword only checks for these:
iskeyword
ans =
'break'
'case'
'catch'
'classdef'
'continue'
'else'
'elseif'
'end'
'for'
'function'
'global'
'if'
'otherwise'
'parfor'
'persistent'
'return'
'spmd'
'switch'
'try'
'while'
Which should be blue (or your color of choice) and completely unusable outside of what it was designed for.
Star Strider
2014 年 2 月 27 日
Good point. Another reason I don’t use it much.
Marco
2014 年 2 月 27 日
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!