Need help regarding publish problem....
7 次查看(过去 30 天)
显示 更早的评论
I have attached a file named test2.m when i publish it using simple publish button. and then search its help in command window using help test2.m its output is following
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164652/image.jpeg)
Why it is showing code which i have written in help. It should show output jut like it should in help window as following.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/164653/image.jpeg)
So how i can overcome this problem??
1 个评论
Chad Greene
2014-6-22
Mujhaid, For this question and any question you ask on this forum, please choose "accept answer" if someone provides an answer that solves your problem. This helps readers with similar problems identify the best solution. It's also a nice way to let folks know when their efforts have helped you.
采纳的回答
Geoff Hayes
2014-6-22
Mujhaid - using publish to publish some code in a script or m-file and running help or doc on a function are two different options (see http://www.mathworks.com/help/matlab/matlab_prog/summary-of-options-for-presenting-your-code-to-others.html) and it can't be assumed that the way one works should work identically for the other.
Each has its own syntax or rules in setting up the help specific to the option. Using help or doc seems to look for a comment block that is above or below the function signature. It uses that in its help documentation this is presented to the user. That is why you are seeing all the publish markup code in the Command Window. Having the html folder of the published functions (or scripts) in the same directory as the function (or script) that you are requesting help on seems to add the
Published output in the Help browser
showdemo test2
comments and link whenever you evaluate help test2.
I suppose that one way to satisfy the help and doc commands against your function and to publish the data is as follows: write the help friendly comments above the function signature, and write the publish friendly comments below the function signature
% TEST2 Does some stuff
% C = test2(A) does something with A
% C = test2(A,B) does something with A and B
%
% See also AXIS, GRID.
function [C] = test2(A,B)
code for the publish function.
Now when you go to publish this file, export the html file to some directory other than html in the directory of the (in this case) test2.m file. Or not, and just accept the fact that when you type help test2 you will see the following
test2 Does some stuff
C = test2(A) does something with A
C = test2(A,B) does something with A and B
See also axis, grid.
Published output in the Help browser
showdemo test2
with the additional Published output in the Help browser….
There is some duplication in the comments (and the one above the function signature will appear in the published file) but it does satisfy the help and publish options.
Try the above and see what happens!
2 个评论
Geoff Hayes
2014-6-24
Mujhaid - you would have to provide an example of what you want to do that is not working as publishing the test2.m with the code from above does work.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 File Operations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!