Can't open created PDF

조회 수: 10 (최근 30일)
Reed Torres Torres
Reed Torres Torres 2018년 4월 23일
댓글: Walter Roberson 2018년 4월 23일
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일
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
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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