Help text does not work for user-defined functions

I just installed R2019b and the help function does not work. Example: I created the addme function from the Add Help for Your Program page in the documentation. Result:
>> help addme
addme is a function.
c = addme(a, b)
The help text in the file was not shown. Also:
>> help help
help not found.
A similar question was asked before, but the answer was not very helpful for me.
help seems to work ok for built-in functions.

9 Comments

Hello Are,
Could you attach your function .m file? And please try to use my attachement.
Regards,
stozaki
Replacing it with your file gives the same result as before.
I tried and got result correctly.Please refer my file attached.
As far as I could understand a similar question has been posted on MATLAB Answer. You can see the thread here and try to follow the solution give there. The error message displayed on the blank help page in that case is slightly different but I believe the solution should help in your case too.
Regards,
stozaki
Earlier, I erroneously reported that the problem had resolved itself. It turns out I was then using my old R2014b, and in 2019b the problem persists. I have tried uninstalling and reinstalling Matlab, with no improvement. I use the same version as you: 9.7.0.1261785 (R2019b) Update 3. I use Windows 10, version 1903.
Any suggestions?
Kind regards,
Are
Which do you select Documentation Location? Installed locally or Web?
Please check your MATLAB preferences.
HOME > ENVIRONMENT Preferences > Help > Documentation Location.
Regards,
stozaki
Documentation Location was set to Local. Changed to Web, with no effect.
As a (temporary?) workaround, I have now written my own 'myhelp' function, which I attach in case others encounter the same problem.
Did following command work fine for you?
which help
If the return value of this command is not the absolute path of the help function, the help function is off the MATLAB search path.
>> which help
C:\Program Files\MATLAB\R2019b\toolbox\matlab\helptools\help.m
In R2014, where help works ok, the help text is created in line 55 of:
C:\Program Files\MATLAB\R2014b\toolbox\matlab\helptools\+HelpUtils\@helpProcess\getTopicHelpText.m:
[hp.helpStr, hp.needsHotlinking] = builtin('helpfunc', '-casesensitive', hp.topic, '-hotlink', hp.command);
In the correponding file in R2019, the help text is created in line 68:
getAlternateSourcedHelp(hp, [], justH1);
I have a similar problem with Matlab R2019a. I use functions that were written in previous versions of Matlab (2014 I think). I can use them, but when I try to get a function's help all it gives me is "myfunction is a function".
If I copy a function's code in a new script and save it from Matlab R2019a, it works correctly. So it is not a mistake in the function's code nor in the help's path. It looks like some kind of encoding error or incompatibilty between versions?
How can I solve this without having to resave 100+ functions?

Sign in to comment.

 Accepted Answer

Problem solved - finally!
My Matlab 2019b and 2020a installations had several other odd behaviours in addition to the help problem. For instance none of the reports available from the Current Folder window worked. I finally decided to investigate this in more detail and found that I had a function strip.m in my Matlab path which shadowed the built-in function with the same name. It gave an error becuse it required two inputs and got only one. The error was not reported there because it was called in a try - catch section. Renaming my function to stripp.m solved both the help problem and the report problem, and some others as well.

1 Comment

Matt J
Matt J on 29 Jun 2020
Edited: Matt J on 29 Jun 2020
Aaarggh. That worked for me, too. They really should use builtins or private/ Mcode for such essential commands.
Good catch.

Sign in to comment.

More Answers (1)

SOLVED – I had this problem as well: some (not all) user-written functions which used to show the correct documentation under r2018b would only show "<function_name> is a function" after updating to r2019b. In my case the problem (as suggested by Oli B) was Legacy Mac EOL encoding – after converting to Unix LF encoding the help for these problematic functions displayed correctly once again. Note that there are many ways to automate this conversion; see e.g. this page.

3 Comments

Thanks for this suggestion. Hopefully, it may help some users. Unfortunately it did not work for me, using Windows 10. I used Notepad++ to change from Windows (\r\n) to Unix line endings (\n) in the addme.m file. The result is the same as before:
>> help addme
addme is a function.
c = addme(a, b)
Did you check file encoding? What works for me under Windows is UTF-8 (EOL either \r\n or \n).
Encoding is UTF-8 and EOL is \n.

Sign in to comment.

Categories

Community Treasure Hunt

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

Start Hunting!