I'm making a program in GUIDE that creates regressions based off given data and plots them. For each plot, a log is created that details the type of plot, its form/constants, and MSE. I was able to successfully do this using a .txt and the following code. A button is pressed to begin the file, using the code
fid = fopen('Logfile.txt','w');
fid = fclose(fid);
Then, each time a regression is made, the following function is called:
function [ ] = logger( message, fileName )
fileID = fopen(fileName,'a');
fprintf(fileID,message);
fclose(fileID);
end
Where each message is a variable made previously and appended to the file. I also intend to save each figure, which brings me to my point. When replacing .txt with .pdf everywhere in the code, I am able to make the .pdf file, but it says damaged and I can't open it. Furthermore, I'm not sure how to save the plot in the GUIDE window to a PDF or how to append a PDF as well. Thanks for the help
EDIT: I am now aware that the procedure for appending .txt files does not apply to PDFs. I'm still looking for a way to compile the figures, and then combine it with the .txt to make a .pdf

2 件のコメント

Walter Roberson
Walter Roberson 2018 年 4 月 23 日
Do I understand correctly that you are attempting to create a .pdf file by simply changing the file extension .txt to .pdf, and otherwise leaving the code the same? Because that would definitely not work.
Reed Torres Torres
Reed Torres Torres 2018 年 4 月 23 日
編集済み: Reed Torres Torres 2018 年 4 月 23 日
Oh, I was unaware that generating PDFs had a different method and that MATLAB can't append them. I don't want to use ghostscript, so I think I will need to find a way to compile all the figures (using some file type) and then convert it to PDF. I also want to add the .txt log to this file, any ideas on what file type or method I should use?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 4 月 23 日

0 投票

Consider using the Report Generator, which is able to create PDF documents. You are able to add text to paragraph objects https://www.mathworks.com/help/rptgen/ug/mlreportgen.dom.paragraph.append.html

3 件のコメント

Reed Torres Torres
Reed Torres Torres 2018 年 4 月 23 日
Is this an additional product/program? If so, I would rather try to find another way
Walter Roberson
Walter Roberson 2018 年 4 月 23 日
https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html
publish() perhaps
Walter Roberson
Walter Roberson 2018 年 4 月 23 日
https://www.mathworks.com/matlabcentral/answers/103861-how-can-i-save-a-word-document-as-a-pdf-via-actxserver-in-matlab-8-2-r2013b
On Windows you can use activex to talk to Word. The interface is enough include images and plots and arbitrary text. Word can be instructed to create a pdf.

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

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

タグ

質問済み:

2018 年 4 月 23 日

コメント済み:

2018 年 4 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by