Can't open created PDF

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 个评论

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.
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 个评论

Is this an additional product/program? If so, I would rather try to find another way
https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html
publish() perhaps
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 Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by