How to change the text on a pushbutton in the code, not using property inspector

3 views (last 30 days)
We have one GUI where a user selects a region from a drop down menu, which is assigned to a number (1 through 6), we then pass that number to another GUI. The second GUI has two ouch buttons labeled city 1 city 2, but we need to change the string to actual city names based on what region the user selected. We set up an if statement for each region and within those if statements we can't figure out how to change the string that the user will see, or how to go about it.

Answers (1)

Geoff Hayes
Geoff Hayes on 19 Apr 2015
Taylor - if you have created your GUI using GUIDE, then you can use the handles structure to access the push buttons and change their text. For example, if pushbutton1 is the name/tag for one of your push buttons, then you could change its text as
set(handles.pushbutton1,'String','Ottawa');
or two whichever city name you wish.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!