How to use publish to create a word document. THANK YOU

21 ビュー (過去 30 日間)
Darren Koh
Darren Koh 2018 年 4 月 5 日
コメント済み: Greg 2018 年 4 月 5 日
Hi everyone, I am new to using the publish function and i intend to code it properly in matlab so that i am able to create a word document in my specific format. I have attached two very simple functions, one with the format that i want and the script that publishes it. Firstly I want to check why is there an error printed 'Not enough input arguments' on my word doc?
The two scripts are attached here.
Script 1:
function reportgen(a,b,c,d,e,f,g)
Results
Summary
fprintf('P1 = %s\n', a);
fprintf('P2 = %s\n', b);
fprintf('P1 = %s\n', c);
fprintf('P2 = %s\n', d);
fprintf('P1 = %s\n', e);
fprintf('P2 = %s\n', f);
fprintf('P3 = %s\n', g);
%%Failed
% Bla Blah and Blaaaa
%%Actions to take
% Redo test P1
% Redo test P2
end
Script 2:
a='hi'
b='woof'
c='meow'
d='adios'
e='hihi'
f='belloo'
g='sup'
reportgen(a,b,c,d,e,f,g)
publish('reportgen.m', 'doc');
winopen('html/reportgen.doc')
Secondly, are there any tips on not displaying the code but only the results? Because this part of the code appears on my word document
fprintf('P1 = %s\n', a);
fprintf('P2 = %s\n', b);
fprintf('P1 = %s\n', c);
fprintf('P2 = %s\n', d);
fprintf('P1 = %s\n', e);
fprintf('P2 = %s\n', f);
fprintf('P3 = %s\n', g);
Lastly, I have attached a screenshot of the word document created. I really appreciate anyone who will spend the time to look through the files thank you :)

採用された回答

Greg
Greg 2018 年 4 月 5 日
編集済み: Greg 2018 年 4 月 5 日
Reading the documentation for publish, it looks like the call to publish executes reportgen, which would indicate that it doesn't pass input arguments. This leads to your not enough input arguments error.
Also, the documentation clearly indicates the 'showCode',false input name-value pair to publish.
And this section of the same documentation page discusses how to pass inputs to the function being published.
  2 件のコメント
Darren Koh
Darren Koh 2018 年 4 月 5 日
Oh my thank you this works like a charm!
Greg
Greg 2018 年 4 月 5 日
Happy to help. Thank you for introducing me to publish.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by