2012-03-27 17 views
9

Tengo una figura abierta con un cierto título. ¿Cómo obtengo la cadena de título?Obtiene el título de la figura actual en MATLAB?

He intentado get(gcf) pero no sé cómo navegar al título.

Quiero obtener el título de muchas figuras, agregar algunos caracteres más a la cadena y volver a escribirla.

Respuesta

21
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) 
+0

impresionante! ¡GRACIAS! ¡Thant es exactamente lo que estaba buscando! – dewalla

0

Dando un asa a una ventana de figura, esto muestra cómo se puede "obtener" y "establecer" el "título" de la figura.

Ejecute las siguientes líneas de código y compruébelo usted mismo. Usé Matlab 2016a.

Aquí se presenta un resumen:

h = figure; 
h.Children.Title.String = 'Your desired title'; 
disp(['Current Figure Title: ', h.Children.Title.String]); 
figure(h); 

Crear una figura de demostración con el título: 'prueba de títulos, 1'

h = figure; 
title('Test Title-1'); 

acceso al título de la figura a través del mango: h

figTitle = h.Children.Title.String; 
disp(['Current Figure Title: ',figTitle]); 
figure(h); 

cambiar la figura título a algo nuevo: 'test Título-2'

h.Children.Title.String = 'Test Title-2'; 
disp(['New Figure Title:',h.Children.Title.String]); 
figure(h); 
Cuestiones relacionadas