write in specific uitable cell
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Software Development Tools 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!