Reputation: 4558
I have noticed that when a function is overridden the help fcn
is not. I created a custom function using the same name as a built in function. Trying:
which fcn
Yields the right\function.m
, but when I use the help
function
help fcn
I get the help for the built in function. However, if I instead type
help fcn.m
I get the correct help. This is ambiguous and disturbing and may lead to confusion about which file is the used one. That is why I wonder: is it possible to override the help as well?.
I know that many does not recommend overriding in matlab, but there are times when it may be worth. For this occation it means that I does not need to change all legacy code where the function is used and also it is not good to have too many version of a function (mycdfplot
is already taken and some may have local versions as well).
Upvotes: 4
Views: 215
Reputation: 11802
Short answer: NO.
(sorry)
To develop a bit: If you overload your own function, you can force the help to point to a specific function by playing with the function precedence order and the order of the path. But for Matlab built-in function, they always take precedence over your custom functions.
The only way for the help to reach your custom function is how you described, by specifying .m
From Matlab (2013b) help:
Note: When multiple programs have the same name, the help command determines which help text to display by applying the rules described in Function Precedence Order. However, if a program has the same name as a MathWorks function, the Help on Selection option in context menus always displays documentation for the MathWorks function.
Upvotes: 1