Borrar filtros
Borrar filtros

two lines title with variable

22 visualizaciones (últimos 30 días)
Abdulaziz
Abdulaziz el 4 de Sept. de 2013
Comentada: Sreepada Ravikumar el 24 de Jun. de 2014
Hi all,
I know how to include variables in title, but is there any way to include variable in title of two lines. I tried to use ({[' ; ']}) with int2str( variable) but it dose not work.
I appreciate your help.

Respuesta aceptada

the cyclist
the cyclist el 4 de Sept. de 2013
Editada: the cyclist el 4 de Sept. de 2013
Here's one way:
m = 1;
n = 2;
figure;
plot(1:10)
title({['Line ',num2str(m),' here'];['Line ',num2str(n),' here']})
  2 comentarios
Abdulaziz
Abdulaziz el 5 de Sept. de 2013
Thank you it works I really appreciate
Sreepada Ravikumar
Sreepada Ravikumar el 24 de Jun. de 2014
Thank U. It worked fine.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 5 de Sept. de 2013
You can create a text string with sprintf(), then use title() to display it:
caption = sprintf('This image is %s\nIt has %d rows and %d columns',...
filename, rows, columns);
title(caption, 'FontSize', 30);
The text string can have the regular format specifiers like you're very much used to if you've done any programming before: %s, %.3f, %d, etc. and you can use \n if you want to go to a new line.

Community Treasure Hunt

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

Start Hunting!

Translated by