how to insert inserted values in legend
    17 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Hossein Alishahi
 el 8 de Mzo. de 2021
  
    
    
    
    
    Respondida: the cyclist
      
      
 el 8 de Mzo. de 2021
            I want to display inserted values to my code in legend. Coud you please give me related code for this. for example
alpha1=input('Enter positive "alpha1"?');
alpha2=input('Enter positive  "alpha2"?');
beta1=input('Enter positive  "beta1"?');
beta2=input('Enter positive  "beta2"?');
lambda=input('Enter positive  "lambda"?');
eta1=input('Enter positive  "eta1"?');
eta2=input('Enter positive  "eta2"?');
P=input('Enter positive  "P"?');
then, all inserted values show in the legend.
Many Thanks
0 comentarios
Respuesta aceptada
  Russel Burgess
      
 el 8 de Mzo. de 2021
        One option is to use sprintf() to make a string, e.g.:
legend(sprintf('alpha1 = %g, alpha2 = %g', alpha1, alpha2));
And so on.  The formatting of inputs to sprintf() is the same as for fprintf() - or "help sprintf" will of course tell you what you need.
0 comentarios
Más respuestas (1)
  the cyclist
      
      
 el 8 de Mzo. de 2021
        I don't fully understand how you want the values to be included, but you'll probably want to use the sprintf command:
alpha1 = 0.1;
beta1  = 0.2;
figure
h = plot(rand(7,2));
legend(h,sprintf("alpha1 = %7.2f",alpha1),sprintf("beta1 = %7.2f",beta1))
0 comentarios
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!



