How do I include help with my P-files from MATLAB?

조회 수: 8 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2010년 1월 20일
편집: MathWorks Support Team 2018년 3월 23일
I used PCODE to pre-parse my MATLAB function files into P-files and then removed the original program files. However, I am now unable to access the help information for the files.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2018년 5월 8일
P-files contain only the parsed MATLAB code. They do not include the help or other comments from the original file. When you use the HELP command, MATLAB looks for a file with the specified name and a .M extension. In order to include help with your P-files, you will need to include a separate .M containing the help comments. If both a .M and .P file exist, MATLAB will call the P-file for execution, so the .M file only needs to contain the help comments.
The following function extracts the help informations from a MATLAB function and saves it into a new file. The help information will be saved in a file with the same name but using an underscore as a prefix.
function help2file(fname)
% HELP2FILE extract the help informations from a MATLAB file and save it separately
% the help information will be saved with the same name but using an underscore as a prefix.
mhelp = help(fname);
fname = [strrep(fname,'.m','') '.m'];
%
fid = fopen(['_' fname],'w');
fwrite(fid,['%' strrep(mhelp,sprintf('\n'),sprintf('\n%%'))]);
fclose(fid);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by