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.
To get the handle of the current figure without forcing the creation of a figure if one does not exist, query the CurrentFigure property on the root object. fig = get(groot,'CurrentFigure'); MATLAB® returns fig as an empty array if there is no current figure.
Create Title and SubtitleCreate a plot. Then create a title and a subtitle by calling the title function with two character vectors as arguments. Use the 'Color' name-value pair argument to customize the color for both lines of text. Specify two return arguments to store the text objects for the title and subtitle.
Specify Figure TitleCreate a figure, and specify the Name property. By default, the resulting title includes the figure number. Specify the Name property again, but this time, set the NumberTitle property to 'off' . The resulting title does not include the figure number.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With