How do I save a figure as the title of the figure?

36 visualizaciones (últimos 30 días)
Anna Frerichs
Anna Frerichs el 3 de Feb. de 2020
Respondida: Jeremy el 3 de Feb. de 2020
I generate a figure with this code:
figure(1)
hold on
surf(xi, yi, Z)
title('WT 0HR', 'fontsize', 20)
....
set(gca, 'fontsize', 14, 'color','k')
set(gcf,'Color',[1,1,1])
Then I want to save the file as the title name as a tiff (eg. WT 0HR.tif)
thanks!

Respuesta aceptada

fred  ssemwogerere
fred ssemwogerere el 3 de Feb. de 2020
Editada: fred ssemwogerere el 3 de Feb. de 2020
This should do nicely for you.
handle=figure;
title_name='WT 0HR';
title(title_name, 'fontsize', 20);
surf(xi, yi, Z);
saveas(handle,title_name,'tiff');

Más respuestas (1)

Jeremy
Jeremy el 3 de Feb. de 2020
Assign your title to an object
th = title('WT 0HR', 'fontsize', 20);
And extract the title string using dot syntax, and use it in the save command
save([th.String,'.tif'])

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by