Using export_fig for custom filenames and specific file folders.

3 visualizaciones (últimos 30 días)
awezmm
awezmm el 14 de Oct. de 2017
Respondida: Walter Roberson el 14 de Oct. de 2017
I'm trying to set the file name for export_fig as a variable. For instance, I could ask a user what they wanted to save a figure as and then save the figure with their answer. How would I do this?
Additionally, I want to save figures to a specific folder on my computer. What is correct syntax for this?

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Oct. de 2017
[filename, pathname] = uiputfile( {'*.tif', '*.png', '*.pdf'}, 'Select an output file');
if isnumeric(filename) %watch out for user cancel
disp('Canceled!')
else
fullname = fullfile(pathname, filename);
[~, ~, ext] = fileparts(fullname);
opts = {'-a1', '-png'};
if strcmp(ext, '.pdf'); opts{end+1} = '-pdf'; end
export_fig(fullname, opts{:});
end

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by