POPMENU cb1 and IUTABLE: UITB1

1 view (last 30 days)
Dany León
Dany León on 29 Jan 2015
Commented: Dany León on 4 Feb 2015
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 Comments
Geoff Hayes
Geoff Hayes on 29 Jan 2015
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
Dany León on 30 Jan 2015
YES, IN MENU HAS 3 OPTIONS FOR EACH OPTION THE "uitable" OBJECT IS FILLED WITH A DIFFERENT DATA

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 1 Feb 2015
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 Comments
Geoff Hayes
Geoff Hayes on 3 Feb 2015
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
Dany León on 4 Feb 2015
Geoff Hayes thanks a lot

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!