我寫了matlab代碼,我想在word(.doc)文件中寫結果。我怎麼能夠? 我用下面的代碼,但不知道如何在word文件中寫'c'的值。其中c = a + b;如何用MATLAB代碼編寫微軟的word文件?
clc;
word = actxserver('Word.Application');
word.Visible = 1;
document = word.Documents.Add;
selection = word.Selection;
selection.TypeText('Hello world. ');
selection.TypeText('My name is Professor Kitchin');
selection.TypeParagraph;
selection.TypeText('How are you today?');
selection.TypeParagraph;
selection.TypeText('Big Finale');
selection.Style='Heading 1';
selection.TypeParagraph;
a=34;
b=23;
c=a+b;
H1 = document.Styles.Item('Heading 1');
H1.Font.Name = 'Garamond';
H1.Font.Size = 20;
H1.Font.Bold = 1;
%H1.Font.TextColor.RGB=60000; % some ugly color green
selection.TypeParagraph
selection.TypeText('That is all for today!')
document.SaveAs2([pwd '/test.docx']);
所有除我不知道怎麼寫的C值在Word文件,就像我們在文本文件fprint打印變量的值是工作的罰款。
我想你可以這樣做:http://uk.mathworks.com/products/ML_reportgenerator/或只是將它保存爲一個txt(無結構化文本)或CSV (結構化),然後使用msword轉換爲docx。 – GameOfThrows