MATLAB [Matlab] Gui help for adding code

  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    Code Gui Matlab
AI Thread Summary
The discussion revolves around creating a GUI button in MATLAB and adding functionality to it. The user initially struggles with understanding where to insert their code for the button's callback function. They clarify that they want the button to display "Go, go, go, world" in the command window when pressed. After receiving guidance, they realize that the code should be placed at the bottom of the callback function. The conversation emphasizes the importance of callback functions in GUI programming, explaining that these functions are executed when a button is pressed, allowing for various actions like displaying messages or performing tasks. The user confirms their understanding of how the callback function works and seeks clarification on the mechanics of calling the function.
mech-eng
Messages
825
Reaction score
13
Hi, all there is an example for gui but I can not do. Could somebody help me. I generated a button in gui then I have to add some function on in. Codes are in the picture. Will I add them under callback function? Why can I not determine where I should I add them. To understand it
what background should I have?
 

Attachments

  • Untitled.png
    Untitled.png
    7.5 KB · Views: 650
  • I have to add them here.jpg
    I have to add them here.jpg
    26.9 KB · Views: 727
Last edited:
Physics news on Phys.org
If you're looking for help you need to supply more information than this screenshot. As it stands, I can't tell if you're writing a Java program or a C/C++ program or even some other language.

With respect to the call back function, often when defining a GUI button you must supply a function that will be called when the button is pressed. Within this function you can do some action like save data to a database or file, start a new thread of execution to do something or to exit a program...

Whatever action is done, we usually try to do it quickly within a 1/10 second or so, so that the enduser views the program as being responsive.
 
There are two screenhots second one is .m file which is specific for only MATLAB and the second screenshot
is the codes I need to insert into it. I launched Gui in MATLAB then generated a button and edited it with
inspector. Now I am trying to see in the command window "Go, go, go , world" after pushing it. Is it clear enough now?
 
I solved the problem. Thank you for help. I have to just add it bottom of the callback function. But while we are already on this topic can you say why we add them bottom of that function
to write screen "go, go, go, world" after pushing the button.

Best Regards.
 
My guess is that when the Button is pressed GoButton is called and the disp('go go ...') is called which prints the message to the console. Is that what you mean?
 
Yes, you are right but what do you mean by GoButton is called?
 
Sorry, I meant the GoButton callback function shown in your second image.
 

Similar threads

Replies
5
Views
3K
Replies
6
Views
2K
Replies
4
Views
4K
Replies
1
Views
3K
Replies
4
Views
1K
Replies
1
Views
2K
Replies
3
Views
2K
Replies
12
Views
3K
Back
Top