フィルターのクリア

how do I find where a function is defined (equivalent of "which" command in bash)

1 回表示 (過去 30 日間)
PeterB
PeterB 2021 年 7 月 14 日
編集済み: PeterB 2021 年 7 月 14 日
When I start Matlab on one of my work machines, I get the message:
"Warning: Function count has the same name as a MATLAB builtin.."
I know exactly what the message means, but I do not know how to fix it, because I can not find where I have defined the function "count". If this was in a bash shell I would type the command "which count". Is there a Matlab equivalent, which shows me where the function "count" has been redefined?
  1 件のコメント
PeterB
PeterB 2021 年 7 月 14 日
編集済み: PeterB 2021 年 7 月 14 日
Thanks everyone. I feel a bit silly not trying all permutations. I tried:
which(count)
but not
which count
or
which("count")
which both worked. I was just a bit disoriented not being at my normal desk and without my glasses!

サインインしてコメントする。

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 7 月 14 日
編集済み: Cris LaPierre 2021 年 7 月 14 日
Yes, there is a which command in MATLAB. Note that count is an overloaded function, meaning it exists in several toolboxes. Here are the results in R2021a.
which -all count
built-in (/MATLAB/toolbox/matlab/strfun/count) count is a built-in method % Shadowed string method /MATLAB/toolbox/matlab/codetools/@mtree/count.m % Shadowed mtree method /MATLAB/toolbox/matlab/bigdata/@tall/count.m % Shadowed tall method /MATLAB/toolbox/parallel/parallel/@codistributed/count.m % Shadowed codistributed method
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 7 月 14 日
Yes, the user will always see that message on startup.
C:\Program Files\MATLAB\R2020a\toolbox\local\count.m
What is the point of that? It is shadowed with the current path settings, so it will not be invoked -- the strfun\count version will be invoked for datatypes other than the ones listed as having @ .
If the intent is to have it be active only for a particular data type, you should build it into the class for that datatype.
PeterB
PeterB 2021 年 7 月 14 日
編集済み: PeterB 2021 年 7 月 14 日
I didn't create it so I don't know what the intention was. (It's not the computer I usually use.) But thank you: now I know why it is giving the warning, and why I am getting a warning for the "count" function and not for anything else.

サインインしてコメントする。

その他の回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 7 月 14 日
  1 件のコメント
PeterB
PeterB 2021 年 7 月 14 日
Thanks. I feel a bit silly now. See my comment below the question.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeHistorical Contests についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by