[Matlab] Gui help for adding code

  • Context: MATLAB 
  • Thread starter Thread starter mech-eng
  • Start date Start date
  • Tags Tags
    Code Gui Matlab
Click For Summary

Discussion Overview

The discussion revolves around adding code to a GUI button in MATLAB. Participants are seeking assistance with understanding how to implement functionality within the callback function of a button they created in the GUI.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant expresses difficulty in determining where to add code within the callback function for a GUI button in MATLAB.
  • Another participant requests more information to provide effective help, noting the importance of understanding the programming context.
  • A participant clarifies that they are working with MATLAB and shares their goal of displaying a message in the command window upon button press.
  • One participant reports solving their issue by adding the code at the bottom of the callback function and seeks clarification on the reasoning behind this placement.
  • Another participant speculates that pressing the button triggers the callback function, which executes the code to display the message.
  • A follow-up question is raised regarding the terminology used to describe the callback function associated with the button.

Areas of Agreement / Disagreement

Participants generally agree on the need to place code within the callback function to achieve the desired outcome, but there is some uncertainty regarding the terminology and the specifics of the implementation process.

Contextual Notes

The discussion lacks detailed information about the specific code being used and the exact structure of the GUI, which may affect the clarity of the assistance provided.

Who May Find This Useful

Individuals working with MATLAB GUI development, particularly those seeking guidance on callback functions and code integration.

mech-eng
Messages
826
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: 672
  • I have to add them here.jpg
    I have to add them here.jpg
    26.9 KB · Views: 751
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 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
6
Views
4K
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K