- The difference in the views is because when we use Publish a proper formatted HTML page is rendered in the web-browser. On the other hand, when we use ‘help’ command for the same function it uses a plain-text format to display the information.
- For built-in functions like “optimoptions” information is displayed in proper UI when hovered over and pressed F1, because separate HTML pages are created for each of such functions.
Getting published markup to work correctly
5 vues (au cours des 30 derniers jours)
I am trying to make some good looking help texts for a bunch of functions. I am trying out the publish option, which I never used before, and I am having a bit of troubles with it.
I made a test function (test_f.m) to get acquainted with the publishing function. Firstly, I just copy/pasted an example from the Publishing Markup documentation from mathworks (https://se.mathworks.com/help/matlab/matlab_prog/marking-up-matlab-comments-for-publishing.html):
%% Vector Operations
% You can perform a number of binary operations on vectors.
A = 1:3;
B = 4:6;
%% Dot Product
% A dot product of two vectors yields a scalar.
% MATLAB has a simple command for dot products.
s = dot(A,B);
%% Cross Product
% A cross product of two vectors yields a third
% vector perpendicular to both original vectors.
% Again, MATLAB has a simple command for cross products.
v = cross(A,B);
And then I published it to see how it worked. Now after publishing, if I type help test_f in the command window or hover over the test_f and press f1 I get this:
Which doesn't look good at all.
If I follow the link for showdemo_test_f a new window is opened:
Which shows the help text just as I want it.
My question is whether it is possible to get this correctly looking help text to be displayed when you use f1 amd similarly get something more that 2 lines and a hyperlink when using help test_f?
I just have an additional question: Are you ment to make a seperate .m file for the help text or could you have both the help text and the actual code for the function in the same .m file?
Divyanshu le 29 Août 2023
I understand the issue you are facing; you can go through the following explanation:
However, if you want to get similar UI then you can make use of ‘publish’ function which can be called directly from your MATLAB script.
For more details about ‘publish’ function of MATLAB refer the following documentation: