Hi all,
When I want to check if a name for a new variable I want to use is already part of Matlab language I just seek help on that word (hopping to get 'word' not found). I guess this is a common practice.
I tried to use this technique with the word 'Str' (short name for a string) and got help on the known function 'std'. Either it is a bug or part of Matlab attempt to guess typos. In both cases, it doesn't help...
Is it a typo correction? Is it a bug?
Thanks,
Alon

댓글 수: 1

Walter Roberson
Walter Roberson 2017년 1월 29일
Yes, occasionally MATLAB does clean up typos or redirect one word to the MATLAB equivalent of that concept. On occasion (not often) I have seen it direct to help that contained a copy of the word I had typed in.

댓글을 달려면 로그인하십시오.

 채택된 답변

Stephen23
Stephen23 2017년 1월 29일
편집: Stephen23 2017년 1월 29일

1 개 추천

Don't use help to check if a name is already used: the best function for this is which:
which str
which str -all
For example:
>> which str
'str' not found.
>> which std
C:\Program Files\MATLAB\R2010b\toolbox\matlab\datafun\std.m

댓글 수: 3

Alon Rozen
Alon Rozen 2017년 1월 29일
Hi Stephen,
Thanks! I learned something new. Didn't know about this 'which' option. It is better then 'help', I agree.
Just for curiosity, I still wonder about the 'help str' behavior. Is it a bug?
Alon
Stephen23
Stephen23 2017년 1월 29일
@Alon Rozen: I suspect that help is trying to, err, help, by providing some spelling correction.
Steven Lord
Steven Lord 2017년 1월 30일
This feature was introduced in release R2015b. It is not a bug.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2017년 1월 29일

댓글:

2017년 1월 30일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by