write in specific uitable cell

조회 수: 2 (최근 30일)
naouras saleh
naouras saleh 2019년 11월 4일
댓글: naouras saleh 2019년 11월 4일
hello
i made an uitable and puch button with editable cell using the code below:
app.UITable.ColumnName={'position 1'; 'position 2 '; 'position 3 '; 'position 4 '};
t = app.UITable;
set(t,'data',ones(5,4))
set(t,'ColumnWidth',{100})
set(t,'ColumnEditable',logical([1 1 1 1]))
push button code:
function EntreButtonPushed(app, event)
t = app.UITable;
l= get(t, 'data');
xlswrite('sasa', l);
end
my questions are:
1- how can i add numeric numbers with (.) dot, (string data)?
2- the colume names of my table are not showen in the save file how can i add them? (ERROR: it is shownen that only accept numeric value and it is not array)
3-and finally, how can i add data to specific cells? like making some cells in uitable constant with particular value?
thanks

답변 (1개)

Walter Roberson
Walter Roberson 2019년 11월 4일
2:
if ~iscell(l)
l = num2cell(l);
end
l = [app.UiTable.ColumnName; l];
xlswrite('sasa', l);
3:
t.Data(Row, Column) = value;
However, making selected cells un-editable might be tricky. It is probably best to copy the "constant" values back in before writing the data to file.
  댓글 수: 3
Walter Roberson
Walter Roberson 2019년 11월 4일
function EntreButtonPushed(app, event)
t = app.UITable;
l = get(t, 'data');
if ~iscell(l)
l = num2cell(l);
end
l = [app.UiTable.ColumnName; l];
xlswrite('sasa', l);
end
naouras saleh
naouras saleh 2019년 11월 4일
i have tested your code it shows error:
Unrecognized method, property, or field 'UiTable' for class 'app1wwwww'.
Error in app1wwwww/EntreButtonPushed (line 68)
l = [app.UiTable.ColumnName; l];
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 335)
Error while evaluating Button PrivateButtonPushedFcn.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by