1

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]);   

enter image description here

mari
  • 107
  • 1
  • 10

1 Answers1

0

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.):

enter image description here

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
  • First of all thank you for your advice. You are right this is definitely what l was trying to do. l appreciate for your attention one more time thanks :D – mari Jan 26 '15 at 13:12
  • @meryem You're welcome. If that was the answer you were looking for, please accept it by clicking on the green check mark on the left to indicate the system that the problem is solved. Thanks :) – Robert Seifert Jan 26 '15 at 13:16
  • @peter but yes l crossed a fault which is : Warning: Table data is not editable at this location. So l want to fill it by hand l will look at it how is this possible but if you let me know anything more l can make this work will be so nice let me know thanks again :) – mari Jan 26 '15 at 13:19
  • Is the code like in my answer is working for you? Please edit your question, so I can copy&paste it and see what is your problem. – Robert Seifert Jan 26 '15 at 13:26
  • @peter l have edited my question can you have a look please thanks again :) – mari Jan 26 '15 at 13:37
  • @meryem Why Peter? I don't get your warning. Generlly warnings do no harm, if everything else is working. If you want to get rid of it, please post your complete code and tell when exactly the warning shows up. – Robert Seifert Jan 26 '15 at 14:12
  • @peter l am not able to fill the table at all. It deletes after l click one another column to fill and l got this warning. Also l am getting these first and second column from .mat file l don't know whether other part of code will make chance this warning? Let me know if it is? – mari Jan 26 '15 at 14:17
  • @meryem Do say if other parts of the code are producing the warning, you need to post the other code. – Robert Seifert Jan 26 '15 at 14:20
  • l find the mistake was about data which l load from .mat file. Finally l solved it and l need to thank you one more time @thewaywewalk :) – mari Jan 26 '15 at 15:09
  • @meryem You're welcome. But the best thank you would be to click the green check mark left of my answer ;) – Robert Seifert Jan 26 '15 at 15:20
  • @meryem you don't need any reputation for *accepting answers*, though you do for *upvoting* :) Also I'd recommend to [take a tour](http://stackoverflow.com/tour) - Accepting answers serves to help distinguish between solved problems and those which need more attention. Upvoting is to indicate which of the answers is helpful or what questions are well asked or interesting. – Robert Seifert Jan 27 '15 at 09:02
  • 1
    lt is done and one more time thanks @thewaywewalk :) – mari Jan 28 '15 at 14:51