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 8845353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:43:09+00:00 2026-06-14T11:43:09+00:00

Is there a way to create two toggle buttons in a Matlab GUI such

  • 0

Is there a way to create two toggle buttons in a Matlab GUI such that one toggles the other? In other words, if button A is on, how can I create a button B that when turned on makes A go off?

  • 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-14T11:43:12+00:00Added an answer on June 14, 2026 at 11:43 am

    I have version R2009a, so I don’t know if this works for you or not:

    I defined two push buttons with guide (with default names). When the first is clicked it is disabled (Enable: Off), its Value set to 1 and its String to On; the second push button is set to the other state. A similar behavior is given to the other button.

    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    set(handles.pushbutton1,'Value',1,'String','On','Enable','Off')
    set(handles.pushbutton2,'Value',0,'String','Off','Enable','On')
    get(handles.pushbutton1)
    
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    set(handles.pushbutton1,'Value',0,'String','Off','Enable','On')
    set(handles.pushbutton2,'Value',1,'String','On','Enable','Off')
    

    If you want to toggle the behavior of button2 according to the state of button1 then do the following:

    % --- Executes on button press in pushbutton1.
    function pushbutton1_Callback(hObject, eventdata, handles)
    
    % this toggles button1 between 0 and 1 and its label between 'On' and 'Off'
    p = 1-get(handles.pushbutton1,'Value');   
    set(handles.pushbutton1,'Value',p)
    if p==0
        set(handles.pushbutton1,'String','Off')
    else
        set(handles.pushbutton1,'String','On')
    end
    
    
    
    % --- Executes on button press in pushbutton2.
    function pushbutton2_Callback(hObject, eventdata, handles)
    
    % Behavior of button2 is dependent on state of button1
    p = get(handles.pushbutton1,'Value');
    
    if p==0
        % Do this when button1 has its label to 'Off' (and Value to 0)
    else
        % This will execute when button1 has a Value of 1 (and its label showing 'On')
    end
    

    Is this what you need?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any possible way to create two storyboards, one portrait and one landscape,
Is there any way to create two iOS applications from one target and project
Is there a way to create two dimensional NSArray without nesting arrays in the
Is there a way with IntelliJ Idea, to create two kinds of artifacts -
Is there a way to create a callback function that fires when a list
Is there any way to create a dynamic Pinterest button? I'm trying to add
Is there way to create just one page for login and reset password? I
Is there a way to create two separate update channels for a Firefox extension
Is there a way to set up two groups of radio buttons in Rails?
Is there a way to use RequestFactory to create two entities in a single

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.