How can l assign values in uitable?

て烟熏妆下的殇ゞ 提交于 2020-01-24 21:10:06

问题


I am trying to figure out how can I assign values in uitable. I got the table size from my data matrix automatically and I am able to define values in first two columns as I want but I don't know how can I fill the third column. Is that possible to fill this column by hand? During trying to fill third column I am getting a Warning: Table data is not editable at this location.

Appreciate for your help.

a = text2(:,(1:c11));
b = in_matrix(1,(1:c11));
cnames = {'Name','Name','Value'};
rnames = 1:c11;
Data = transpose(a);
f = figure('Position', [100 100 500 500]);
t = uitable('Parent', f, 'Position', [50 100 300 400],...
        'Data',Data,...
        'ColumnName',cnames,...
        'RowName',rnames,...
        'Enable','on',...
        'Visible','on');   
set(t,'ColumnFormat',{'char','char','numeric'});
set(t,'ColumnEditable',[false,false,true]);   


回答1:


First, don't use text as a variable name, as it is an in-built function, which can cause trouble. Second, this is what I think you have so far:

content = {'neuer Schaufeltyp'         '[]'    [     0.8]; ...
'Geometrienummer'           '[]'    [ 0.16667]; ...
'neuer Bearbeitungstyp'     '[]'    [ 0.29231]; ...
'D'                         '[]'    [0.066667]; ...
'L1'                        '[]'    [ 0.73529]; ...
'Schneiden'                 '[]'    [     0.1]; ...
'fz'                        '[]'    [     0.1]; ...
'Einstellwinkel'            '[]'    [       0]; ...
'Schneidenradius'           '[]'    [       0]; ...
'Kühlung'                   '[]'    [ 0.33333]; ...
'GleichGegen'               '[]'    [       1]; ...
'Verh. D-WZ/Eingriffsbr'    '[]'    [       0]; ...
'neuer Werkstoff'           '[]'    [ 0.11111]}.';

c11 = 13;
a = content(:,(1:c11));
cnames = {'Name','Name','Value'};
rnames = 1:c11;
Data = a.';
f = figure('Position', [100 100 500 500]);
t = uitable('Parent', f, 'Position', [50 100 300 400],...
        'Data',Data,...
        'ColumnName',cnames,...
        'RowName',rnames,...
        'Enable','on',...
        'Visible','on');

Now I'm a little confused, do you want to fill the second column or the third? Do you want to do it by code or by hand?

To fill the third column by hand you need to make it editable using the property ColumEditable and rather define the ColumnFormat also:

set(t,'ColumnFormat',{'char','char','numeric'})
set(t,'ColumnEditable',[false,false,true])

or do it at the beginning together with all other properties.

and you get your table, where you can manually insert the values in the third column (I inserted the 42 always.):



来源:https://stackoverflow.com/questions/28148841/how-can-l-assign-values-in-uitable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!