Assigning strings to GUI buttons from an mfile?

1 view (last 30 days)
I'm just starting to get to grips with the Matlab GUI. I'm trying to build a response interface for a serial recall task. I want a series of buttons, each of which has a letter on it (i.e. string). when the button is pushed, the letter appears in a text box, reflecting the order in which the buttons were pushed. One box per button. The catch is that the string assigned to each button needs to be different on every trial, so I can't just set it using the property inspector. I assume this can be assigned from an mfile, but I'm not sure how! Any help appreciated.

Answers (1)

Daniel Aldrich
Daniel Aldrich on 25 Feb 2015
To change the string of a button from inside the mfile you have to use the set function in the following manner:
%Sets the String of button, Button_Tag, to 'string goes here'
set(handles.Button_Tag,'String','string goes here')
%Forces the figures to update with minimal delay
drawnow
  1 Comment
John Taylor
John Taylor on 25 Feb 2015
Using handles.Button_Tag will assign the 'string' to the button when it's pushed. What I need is for the string assigned to the button by default i.e. when the GUI launches, the string is already assigned to the button.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!