How do I redirect "help" output to text file within iterative loop?

Hello,
I would like to execute "help fxn_name{jj}" from with a loop and redirect all output to a text file.
Below is an excerpt of my code. fid_in is a report from depfun() that has a list of "m-files". I want to read each member of the list and execute "help" on that function, then write name and the corresponding "help" info to fid_out.
This sets up depfun properly:
[list,builtins,classes,prob_files,~,eval_strings,called_from] = depfun(fun,'-toponly','-print',ofilename);
I use outputs of depfun to perform the following:
for jj=1:numfiles,
tline=fgetl(fid_in) %processing already done to remove unneeded info.
fxn_name{jj}=tline(lastslash+1:end);
fxn_name_path{jj}=which(fxn_name{jj});
fxn_name_index{jj}=num2str(find(ismember(list,fxn_name_path{jj})));
fprintf(fid_out,'%i',str2num(fxn_name_index{jj}));
fprintf(fid_out,' %s',fxn_name{jj});
str=['help ' fxn_name{jj}];
fprintf(fid_out,'%s',eval(str));
end
MATLAB's "help" command is unique and seems to be the source of my problem.
Suggestions?

 採用された回答

Walter Roberson
Walter Roberson 2014 年 2 月 21 日

1 投票

You should be using evalc() rather than eval()

その他の回答 (1 件)

Derek
Derek 2014 年 2 月 21 日
編集済み: Walter Roberson 2014 年 2 月 21 日

0 投票

You are correct, but can you tell me why I get <strong> and </strong> inserted?
For example, one line of the text file should read:
function [out, hp]=Mlsm_modulator(bitseq,BAUD,os,BW_par,plt)
but it reads:
function [out, hp]=<strong>Mlsm_modulator</strong>(bitseq,BAUD,os,BW_par,plt)
Notice the insertion of <strong> and </strong>>.
Is this a fluke of evalc() or is this a result of my poor implementation of fprintf formatting?
Derek

2 件のコメント

Walter Roberson
Walter Roberson 2014 年 2 月 21 日
"help" is putting the strong in there. You can see it when you use "help" at the command line. evalc() is capturing exactly what help() is writing.
Time to break out the regexprep()
It appears that <strong> is obeyed anywhere in console output. I have not tracked to see what else is obeyed.
Derek
Derek 2014 年 2 月 22 日
Now it makes sense. Thank you Walter.

サインインしてコメントする。

カテゴリ

製品

タグ

質問済み:

2014 年 2 月 21 日

コメント済み:

2014 年 2 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by