Assigning strings to GUI buttons from an mfile?

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.

Réponses (1)

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 commentaire

John Taylor
John Taylor le 25 Fév 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Produits

Tags

Commenté :

le 25 Fév 2015

Community Treasure Hunt

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

Start Hunting!

Translated by