Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get title of current figure in MATLAB?

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.

like image 675
dewalla Avatar asked Mar 27 '12 20:03

dewalla


People also ask

How do you get a handle of a figure in MATLAB?

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.

How do you title a plot in MATLAB?

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.

How do you name a figure in MATLAB?

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.


1 Answers

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)
like image 178
Chris Avatar answered Oct 20 '22 00:10

Chris