GUI how to display table data into figure
Afficher commentaires plus anciens
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);
Réponse acceptée
Plus de réponses (1)
Khanh
le 30 Déc 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.
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!