GUIDE: Duplicated elements without duplicated functions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
David Sanchez
le 4 Fév 2014
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.
0 commentaires
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!