GUIDE: set handle with function

10 views (last 30 days)
Lorenzo
Lorenzo on 7 Jul 2013
Dear all;
I'm building a GUI with GUIDE and I have few tables. Now, for every each one of those tables I want to set the data according to different conditions (related to a different popup assigned to each table) and if the conditions are the same for two different tables then the data I'm setting are the same for the two tables. Now, to do so, it would be nice if I could use the same function for all of those table. What I have so far is this (for table 1 taken as an example):
function popupmenu1_Callback(hObject, eventdata, handles)
val1 = get(hObject,'Value');
table1(val1,handles)
And inside the function called table1 I have:
function [a]=table1(val1,handles)
if val1 == 1
set(handles.uitable1,'Data',list_a,'Enable','off')
elseif val1 == 2
set(handles.uitable1,'Data',list_b,'Enable','on')
elseif val1 == 3
[...]
Now, for the other tables I have the same thing but instead of calling the function table1 I'm calling table2, table3 and so forth which in turn will set handles.uitable2, handles.uitable3 and so on...
Now, is there any way to generalize this and have only one function instead of table1, table2, table3??
Thank you all!

Answers (1)

Image Analyst
Image Analyst on 7 Jul 2013
Sure, just have one function called "SetAllTables" and call that in every function of every control (popup) that needs to do this. In the SetAllTables you can just do all three tables. No need to have one function per table if you don't want to.
  8 Comments
Image Analyst
Image Analyst on 9 Jul 2013
If you want, you can make a function that takes a handle and a popup selection number and send those to a function. But you still have to put a call to that function inside each callback of each popup.
Lorenzo
Lorenzo on 10 Jul 2013
Ok, so I guess I cannot do what I was asking to...
Thank you anyway for your help!

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!