I have a GUI that executes a function that remains in the loop until "Esc" key is pressed or certain amount of time is passed. However, I want to do it using a push button in my GUI is pressed. I am sure there is a simple solution for it.
Thanks!

댓글 수: 7

Rik
Rik 2023년 1월 3일
Can you edit that function?
No and I don't know hwo to do that.
I guess what I am trying to do is to set a flag inside a loop within the function but I don't know how to do it.
Rik
Rik 2023년 1월 3일
Well, if you can't edit the function, then there is no way to change the functionality and you will have to use the escape key. Only if you can edit the function is there any possibility to implement some sort of flag.
Thanks Rik! What if I can modify the function? then how should I proceed from there?
Rik
Rik 2023년 1월 3일
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread. You should probably be able to modify the examples from that threat to suit your needs.
Otherwise, post what you have tried and I'll see what I can do to modify it.
Walter Roberson
Walter Roberson 2023년 1월 3일
There is one possibility that does not involve editing the function itself:
The function just might possibly have been implemented in terms of the function checking to see if a particular stop indication variable has been set, with a key press callback having been established that sets the flag.
If that just happens to be the case, then you could remove the key press callback and add in a button press callback that set the flag.
You would still need to edit something but it would not, in this limited case, be the code loop itself.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2023년 1월 3일

댓글:

2023년 1월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by