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.

回答 (1 件)

Daniel Aldrich
Daniel Aldrich 2015 年 2 月 25 日

0 投票

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 件のコメント

John Taylor
John Taylor 2015 年 2 月 25 日
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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

製品

タグ

質問済み:

2015 年 2 月 24 日

コメント済み:

2015 年 2 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by