How do I insert a variable value in legend of a plot?
225 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Arjun Siddharth
el 6 de Sept. de 2021
Comentada: Arjun Siddharth
el 6 de Sept. de 2021
I have a varible p, with a value -2.2. How do I insert this value in the legend function, for a plot?
eg.- legend('Value 1=p'); % I wish to have the numeric value of p (2.2) in place of 'p'.
0 comentarios
Respuesta aceptada
Murugan C
el 6 de Sept. de 2021
use below code
value_x = 2.2;
value_y = 2.5;
legend(sprintf('Value-X = %g',value_x),sprintf('Value-Y = %g',value_y))
Más respuestas (1)
DGM
el 6 de Sept. de 2021
There are a bunch of examples around. The sidebar shows some. Here are some others:
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!