Get title of current figure in MATLAB?

dewalla picture dewalla · Mar 27, 2012 · Viewed 13.9k times · Source

I have a figure opened with a certain title. How do I get the title string?

I have tried get(gcf) but I don't know how to navigate to the title.

I want to get the title of many figures, add some more characters to the string and write it back.

Answer

Chris picture Chris · Mar 27, 2012
x=0:.1:3.14;
plot(sin(x))
title('Sin(x)')

%get the title
h=get(gca,'Title');
t=get(h,'String') %t is now 'Sin(x)'

%new title
new_t=strcat(t,' Sine function')
title(new_t)