Saving plot as pdf in loop

조회 수: 30 (최근 30일)
Elise
Elise 2015년 8월 5일
답변: Rohit Kudva 2015년 8월 7일
I am trying to save a figure in a while loop as a pdf. Currently I am getting the correct name for the figure but it is saving as .fig instad of .pdf.
Mass_ = 'Mass_map_';
month = name(14:15);
contourf(mydata)
saveas(gcf, sprintf(strcat(Mass_, month),'.pdf'))
Thanks for any help, I am pretty new to matlab so any advice is taken

채택된 답변

Rohit Kudva
Rohit Kudva 2015년 8월 7일
Hi Elise,
The ' sprintf ' function is used for formatting certain input data to string. I am not entirely sure about your use of the 'sprintf' function to define the name for the pdf file. Since your figure is getting saved as a .fig file, I would recommend you to use the following syntax for the ' saveas ' function.
>> saveas(gcf,'MyPDFFileName','pdf');
The above code will save the current figure in a file MyPDFFileName.pdf. Depending on the type & dimensions of the 'name' variable in the code snippet you have provided, you can set the name of the PDF file accordingly.
I hope this helps!
-Rohit

추가 답변 (0개)

카테고리

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