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!

 채택된 답변

Sean de Wolski
Sean de Wolski 2013년 11월 7일
편집: Sean de Wolski 2013년 11월 7일

0 개 추천

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

Lorenzo
Lorenzo 2013년 11월 7일
Thanks Sean. My buttons are still there and there's no duplicated name. I'll ignore them. I guess it is a sort of a bug.
Sean de Wolski
Sean de Wolski 2013년 11월 7일
We like to call it a 'limitation' :)
The way GUIDE works is that inside of gui_mainfcn (the engine running the GUIDE UI) various commands are used to programmatically call the callbacks in the GUIDE generated *.m file. Because these are called from within gui_mainfcn rather than within the generated *.m file itself, the Code Analyzer can't see them and because it can't see them it flags them as not being used.
Lorenzo
Lorenzo 2013년 11월 8일
Thanks! I was afraid I had done something wrong with my GUI!
Valentino
Valentino 2017년 1월 24일
so there is no way around this warnings than ignoring them?
Walter Roberson
Walter Roberson 2017년 1월 24일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

질문:

2013년 11월 7일

댓글:

2017년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by