GUI: unused function warning

2 visualizaciones (últimos 30 días)
Lorenzo
Lorenzo el 7 de Nov. de 2013
Comentada: Walter Roberson el 24 de En. de 2017
Dear all, quick question on a GUI. Let's say you set up a button that plots a graph once pushed. In the editor you need a function like this:
function pushbutton8_Callback(~, ~, ~)
plot(someVariableElsewhereDefined)
Now, the editor will underline this function in red saying that it is unused.
Is this correct? Is there any way to do the same thing without the same "useless" function?
Thanks!

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 7 de Nov. de 2013
Editada: Sean de Wolski el 7 de Nov. de 2013
Typically this happens if you delete the pushbutton or if there is another function with the same name (red underline - otherwise it's orange).
Sometimes, however, this happens on its own with GUIDE generated *.m files. I.e. the Code Analyzer is giving a false positive because it cannot see where the buttons are called from. If the code and pushbutton is working, you can ignore the Code Analyzer messages.
  5 comentarios
Valentino
Valentino el 24 de En. de 2017
so there is no way around this warnings than ignoring them?
Walter Roberson
Walter Roberson el 24 de En. de 2017
You could change the Callback property to directly execute the action using an anonymous function or string. However if you do so then the change is likely to be overridden the first time that you use GUIDE to change the gui.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps 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!

Translated by