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!