Can't open created PDF

10 Ansichten (letzte 30 Tage)
Reed Torres Torres
Reed Torres Torres am 23 Apr. 2018
Kommentiert: Walter Roberson am 23 Apr. 2018
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 Kommentare
Walter Roberson
Walter Roberson am 23 Apr. 2018
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 am 23 Apr. 2018
Bearbeitet: Reed Torres Torres am 23 Apr. 2018
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?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 23 Apr. 2018
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 Kommentare
Walter Roberson
Walter Roberson am 23 Apr. 2018
https://www.mathworks.com/help/matlab/matlab_prog/publishing-matlab-code.html
publish() perhaps
Walter Roberson
Walter Roberson am 23 Apr. 2018
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by