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.

Respuestas (1)

Daniel Aldrich
Daniel Aldrich el 25 de Feb. de 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 comentario

John Taylor
John Taylor el 25 de Feb. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 24 de Feb. de 2015

Comentada:

el 25 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by