How to change an uitable from a listbox? (GUIDE)

2 次查看(过去 30 天)
Hello,
I'm doing a project with GUIDE and I have a problem. The programa have two EditText with one PushButton, one Listbox and one uitable. The user through the first EditText insert one variable to the listbox and with the second EditText the number of rows of the uitable (the columns are fixed) with the following code in the PushButton Callback:
variables = str2double(get(handles.Number,'String'));
columns = 4;
num_elem = cell(variables,columns);
num_elem(:,:)={''};
set(handles.uitable1,'Data',num_elem)
set(handles.uitable1,'ColumnEditable',true(1,columns))
a = get(handles.Name,'String');
str_part = a;
old_str = get(handles.listbox1,'String');
new_str = strvcat(old_str, str_part);
set(handles.listbox1,'String',new_str)
Till now all is correct, the problem commes when there are for instance 3 variables, with 4, 6 and 8 rows and I want to click in the first one and the rows must change to 4, and if a click in the third must change to 8. But I don't know how to do it, the rows keep without change. My code is the following in the Listbox Callback:
num = get(handles.listbox1,'Value');
variables = str2double(get(handles.Numero,'String'));
switch num
case 1
a = zeros(variables,4);
a(:,2)=1;
a(:,4)=1;
set(handles.uitable1, 'Data', a);
case 2
a = zeros(variables,4);
a(:,2)=1;
a(:,4)=1;
set(handles.uitable1, 'Data', a);
end
  • The variable a is do to the uitable must be refill with 1 and 0.Other problem is that there will be as much variables as we want.
Thank you very much

回答(0 个)

类别

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