我如何在uitable中分配值? [英] How can l assign values in uitable?
问题描述
我试图弄清楚如何在uitable中分配值.我可以从数据矩阵中自动获取表大小,并且可以根据需要在前两列中定义值,但是我不知道如何填充第三列.可以手动填写此列吗?尝试填充第三列时,我得到警告:该位置的表数据不可编辑.
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.
感谢您的帮助.
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]);
推荐答案
首先,请勿将text
用作变量名,因为它是内置函数,可能会引起麻烦.其次,这就是我到目前为止所掌握的:
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?
要用手填充第三列,您需要使用属性ColumEditable
使其可编辑,并且还要定义ColumnFormat
:
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.
得到表格,您可以在其中手动在第三列中插入值(我总是插入42.):
and you get your table, where you can manually insert the values in the third column (I inserted the 42 always.):
这篇关于我如何在uitable中分配值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!