How to save data of UITABLE in Workspace
3 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a uitable with 3-columns of which first two are fixed, while the 3rd columns receives input from the user. Now I want to save this new data to somewhere like - workspace/excel file/ mat file. I have following code ==
load data.mat columns={'x','y','z'}; ht = uitable(uitable(data,columns,'Position',[25 90 200 200])); newdata =get(h,'Data'); FileName = uiputfile('*.xls','Save as'); xlswrite(FileName,newdata),
Whenever I run this above matlab gives following error, I can't find solution for this. So any suggestion will be heartly appreciated.
In uitable at 46 In new at 7 Error using horzcat The following error occurred converting from char to opaque: Error using horzcat Undefined function 'opaque' for input arguments of type 'char'.
Error in uitable_deprecated (line 40)
Error in uitable (line 47) [thandle, chandle] = uitable_deprecated(varargin{:});
Error in new (line 7) ht = uitable(uitable(data,columns,'Position',[25 90 200 200]));
Kindly help me out. Thank you.
0 个评论
采纳的回答
Yoav Livneh
2015-2-18
I think you are using uitable wrong. Look at the documentation for this function but I believe it should be something like this:
ht = uitable('Data',data','ColumnName',columns,'Position',[25 90 200 200]);
and then
newdata = get(ht,'Data');
0 个评论
更多回答(1 个)
Giorgos Papakonstantinou
2015-2-18
If you want to get the data whenever the data change use this:
f = figure;
d = randi(100, 7, 3);
t = uitable(f,'Data',d,'ColumnWidth',{50},...
'ColumnEditable', [true true true]);
% GET DATA whenever the data change
set(t, 'CellEditCallback', 'get(t,''Data'')')
1 个评论
Giorgos Papakonstantinou
2015-2-18
I you want specifically to create a variable in workspace whenever data change in you table, try this:
set(t, 'CellEditCallback', 'assignin(''base'',''data2workspace'',get(t, ''Data''))')
or more neatly create a function
function dataChanged(src, evt)
assignin('base','data2workspace',get(src, 'Data'))
end
then
set(t, 'CellEditCallback', @dataChanged)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!