GUI how to display table data into figure
显示 更早的评论
My problem is: I try to read some data from excel file, first display as table data inside Matlab GUI, then I want to display data in the figure (GUI). I know I can re-read the excel data again to display in the figure. But how I can get table handle and transfer to figure as data input? I am a beginner in GUI, please help me. I highly appreciate it.
function uitable1_CreateFcn(hObject, eventdata, handles)
[num,txt,raw]=xlsread('C:\Program Files\data_example.xls');
set(hObject,'data',num,'ColumnName',txt);
handles.uitable1=hObject;
% guidata(hObject,handles);
function axes1_CreateFcn(hObject, eventdata, handles)
tab_data=get(handles.uitable1,'Data') %%%%%always tell me wrong "Attempt to reference field of non-structure array." %%%%
handles.axes1=plot3(tab_data(:,1),tab_data(:,2),tab_data(:,3));
guidata(hObject,handles.axes1);
采纳的回答
更多回答(1 个)
Khanh
2014-12-30
You have to set data for the table before retrieve it.
[num,txt,raw]=xlsread('C:\Program Files\data_example.xls');
% Set data table (num variable is data you want to set)
set(handles.uitable1,'Data',num)
% And then get data table
tab_data=get(handles.uitable1,'Data')
Hope this can help you.
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Identification 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!