フィルターのクリア

GUIDE: Duplicated elements without duplicated functions

1 回表示 (過去 30 日間)
Lorenzo
Lorenzo 2014 年 2 月 4 日
回答済み: David Sanchez 2014 年 2 月 4 日
Dear all, I'm writing a GUI in GUIDE with a lot of duplicated elements. I have 20 tables and 20 textboxes. Depending on the data entered in table_i the value of text_box_i is updated accordingly. Every text box depends on the corrisponding table only and the calculation behind each table+text_box pairing is the same.
What I have at the moment is:
function uitable_1_CellEditCallback(hObject, ~, handles)
c=get(hObject,'Data');
set(handles.text_box_1,'String', num2str(c*2)
This is for table+text_box 1. Since I have 20 pairings, this is repeated 20 times thus making my code long and boring to modify (every small change has to be repeated 20 times...)
Since the only change in the code is the number of the table (which is the same number for the text box), I was wondering if there was any way to do this by having one piece of code only. Something such as (but of course different than):
for i=1:20
function uitable_i_CellEditCallback(hObject, ~, handles)
c=get(hObject,'Data');
set(handles.text_box_i,'String', num2str(c*2)
end
Thanks!
Lorenzo

回答 (1 件)

David Sanchez
David Sanchez 2014 年 2 月 4 日
Every object within your GUI has to have its own callback function, and these have to be defined in your code. You have to code all your callbacks.

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by