GUI how to display table data into figure
Show older comments
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);
Accepted Answer
More Answers (1)
Khanh
on 30 Dec 2014
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.
Categories
Find more on Data Type Identification in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!