POPMENU cb1 and IUTABLE: UITB1
显示 更早的评论
1 I have: POPMENU cb1 and IUTABLE: UITB1
in the object POPMENU desire to click each option and need the object IUTABLE is full.
Each option object POPMENU a different data in IUTABLE. (Data: Data1, Data2, Data3)

2 个评论
Geoff Hayes
2015-1-29
Dany - please clarify what you need help with. Are you just trying to populate the table with data that is dependent upon the item selected in the popup menu?
Dany León
2015-1-30
回答(1 个)
Geoff Hayes
2015-2-1
Dany - if you want to fill the uitable with a different set of data given the selection in the popup menu, then you will need to create a callback for the popup menu and have it respond to the user selection. Something like
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% get the index of the selected value (from the menu: 1, 2, or 3)
selectionId = get(hObject,'Value');
% populate the table with a different set of data depending upon the selection
switch selectionId
case 1
set(handles.uitable1,'Data',1*ones(4,4));
case 2
set(handles.uitable1,'Data',2*ones(5,5));
case 3
set(handles.uitable1,'Data',3*ones(6,6));
end
Note how we use use handles to update the uitable (named uitable1). The above is just a simple example which you should be able to fit for your needs. Try it and see what happens!
5 个评论
Dany León
2015-2-1
Geoff Hayes
2015-2-1
Dany - the code to load the file would be in the pop up menu callback. What do you mean by can not load the data? Are you observing an error or some other problem?
Dany León
2015-2-2
编辑:Geoff Hayes
2015-2-3
Geoff Hayes
2015-2-3
Dany - there are a handful of bugs in the above code. The line
load ('C:\data.mat','data1','data2,'data3');
is missing a single quote around data2 and so should be replaced with
load ('C:\data.mat','data1','data2','data3');
The local variable colummname is undefined, and the property 'ColumnNane' is incorrect and should be 'ColumnName'.
I was able to create a simple example that is very similar to yours, and I can load the uitable. Please make the above corrections and try again. Also, put a breakpoint in the cb1_callback and step through the code to see what the problem might be.
Dany León
2015-2-4
类别
在 帮助中心 和 File Exchange 中查找有关 App Building 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!