Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:12:52+00:00 2026-06-11T04:12:52+00:00

I have a function which can be run in various different ways, depending on

  • 0

I have a function which can be run in various different ways, depending on the state of 42 constants which are set at the top of the code. Up until now, if I want to run my function under different conditions, I simply open the MATLAB code and adjust the constant at the beginning of the code.

Fourty-two constants is a lot to keep track of, and I’ve found myself running experiments with certain switches accidentally left turned on. The obvious solution is to build a GUI, where my inputs can be seen visually in one place. The GUI would simply be a parameter setting window, with a big ‘Go’ button at the bottom which takes the inputs (all 42 of them!) and passes them into my main function.

I have come across GUIDE, which I have used to build a nice GUI. I have managed to get a button to launch my function, but I’m struggling to get the actual variables entered into text boxes and check box states to pass to the main function.

I understand it has something to do with ‘Callbacks’, but the documentation is unclear and seems to be more concerned with building GUIs in which the variables adjust the content of the current window.

As a basic example, I’m working with a check box. I know that when I click a check box, function checkbox1_Callback(hObject, eventdata, handles) executes. I have modified this function so that it returns a variable ‘state’, which is set during the function in the following way:

state = get(hObject,'Value')

This pops up a message saying that state has been changed, whenever I click the check box. Of course, as soon as this has happened, the function has ended and the variable destroyed. There doesn’t seem to be any way of receiving the variable elsewhere. The .m code doesn’t include a call to the checkbox1_Callback function anywhere, so I don’t know where I can receive the input.

I had hoped I could just call the checkbox1_Callback function at the time of clicking the ‘Go’ button, but I don’t know what arguments to pass to the callback.

Clearly I’m missing something fundamental here, but the documentation doesn’t make this easy! Any pointers would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:12:54+00:00Added an answer on June 11, 2026 at 4:12 am

    You will probably only need one callback – on the “GO” button.

    It sounds like you’ve already sorted this out – so you probably have a function like:

    function go_Callback(hObject, eventdata, handles)
    

    which gets executed when you press the “Go” button. If you don’t have it, create it from GUIDE by right-clicking the “Go” button and selecting “View Callbacks”->”Callback”.

    From here, you can ‘pull’ the data from other GUI components. For example, if you have a text box called “threshold”:

    threshold = get(handles.threshold, 'String');
    

    Similarly, for a checkbox:

    checked = get(handles.my_checkbox, 'Value');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have various python function which i intend to run independently. For exmaple ,
Suppose I have a function which can either take an iterable/iterator or a non-iterable
In C and C++ we have the memset() function which can fulfill my wish.
Do MySQL have any function by which I can split data of a column
Can I´m asking for advice. I have function which should return javascript object function
I have a function which takes a custom struct as the argument. how can
Hallo, how can I pass more parameters to usort? I have different functions, which
I have to import library which is called functions.sage . How can I do
hi i have function which is called by tinker listbox so i cannot return
I have a function which looks something like this, it returns a noncopyable class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.