how to save plots ".pdf" in a folder generated by mkdir function?

조회 수: 10 (최근 30일)
I want save my plots in a folder created by mkdir. I am to plot from multiple excel files and save with the excel file name in a folder name as Newfolder. The code generates folder "Newfolder" but save the plots in Parent folder, not in Newfolder. How can I change my code to save the plots in Newfolder. my code looks like this.
mkdir('Newfolder'); saveas(gcf, [basename '.pdf']);

채택된 답변

Walter Roberson
Walter Roberson 2016년 2월 2일
outputdir = 'NewFolder';
if ~exist(outputdir, 'dir')
mkdir(outputdir);
end
saveas(gcf, fullfile(outputdir, [basename '.pdf'])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by