Update the Legend dataN value in GUI
Mostrar comentarios más antiguos
Hi All,
I was following a training video on how to learn to make a GUI(Basic) on a second order dynamic system, using zeta as a variable. I want display the value of zeta everytime I ran the simulation. but I only get dataN values. I have attached the files created as part of the training video - I added the legend commands trying to make it work, but di not work!
Thanks for your help!
Gera

Respuesta aceptada
Más respuestas (1)
%rue
legend(sprintf('\zeta = %d',zeta));
Use sprintf in legend in pushbutton callback function
6 comentarios
Gerardo Ortega
el 15 de Dic. de 2020
%true
legend(sprintf('\zeta = %f',Zeta), sprintf('\zeta = %f',Zeta), sprintf('\zeta = %f', Zeta));
You are using zeta as variable to store damp value. It is built-in function in matlab.
Change it to and Try the above
In your callback function you should change the variable zeta to something like Zeta or ZZeta etc
%true
Zeta = get(handles.slider1,Value)
VBBV
el 15 de Dic. de 2020
However using a \ e.g. \zeta will not have problem. It will produce symbol instead
Walter Roberson
el 16 de Dic. de 2020
zeta is not a reserved word.
Avoiding using a variable name should be done if:
- the name is easy to confuse with other names, such as l1 being easy to confuse with 11
- the name is used so often for one purpose that seeing it will cause confusion, such as pi = sqrt(2)
- the name is the same as a frequently used function so it is likely to confuse readers, such as length
- the name is so commonly used as a function that you are likely to confuse yourself, such as sum
- assigning to the name can make use difficult, such trying to remove a variable named "clear"
In most circumstances zeta does not fall under any of those. There is a zeta function but the use is so uncommon that people are more likely to think of zeta as a variable instead of a function.
Walter Roberson
el 16 de Dic. de 2020
Using \zeta inside sprintf because \ introduces escape sequences in that context. \n \t and so on. \z is not a valid escape and will lead to errors. You need \\zeta
Categorías
Más información sobre Legend en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!