How to save a figure in a different directory and with a dynamic name using export_fig?

조회 수: 5 (최근 30일)
Hello! I am using export_fig to save the plots I am producing with matlab. What I want to do is:
  1. Save the figures in a different directory than the one I am working.
  2. Give a dynamic name to the saved figure according to the file that the program is reading every time.
  3. Use the command -transparent to remove the grey area around the figure.
My code is this:
baseFileName = sprintf('mass_conc_%s',sprintf('%s',char(cellstr(date.date(1)))));
saveas(gcf,baseFileName,'pdf')
export_fig baseFileName -transparent
This code is not saving the .png file (produced with export_fig) with the same name as the pdf file and I cannot specify another directory for saving it.
Thank you in advance for your help! Dimitra

답변 (1개)

Thorsten
Thorsten 2016년 7월 19일
Some hints, since it appears to be homework:
help fileparts % separate path, name and extension
help fullfile % to generate a new full filename
Use the functional syntax of print and export_fig, i.e., use parentheses (...)
export_fig(newfilename, 'transparent') % not sure if this is the right syntax

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by