GUIDE: set handle with function

4 次查看(过去 30 天)
Lorenzo
Lorenzo 2013-7-7
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!

回答(1 个)

Image Analyst
Image Analyst 2013-7-7
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 个评论
Image Analyst
Image Analyst 2013-7-9
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 2013-7-10
Ok, so I guess I cannot do what I was asking to...
Thank you anyway for your help!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by