Problem with plotting/updating the graph in the GUI.
Ältere Kommentare anzeigen
I have an excel file with 3 columns 'time', 'X-axis' and 'y-axis' and I want to read this Excel sheet via GUI in matlab and plot a graph in GUI. I used two popupmenus (popupmenuX and popupmenuY). I want to display the column names in these popupmenus which I was fine with. But the plot was not generated after I selected the column names in the corresponding axis.
This is my code:
handles.filename = uigetfile('*.xlsm')
guidata(hObject, handles)
setPopupmenuString(handles.popupmenuX, eventdata, handles)
setPopupmenuString(handles.popupmenuY, eventdata, handles)
set(handles.popupmenuX,'callback','@(hObject,eventdata)mainGUI(''updateAxes'',hObject,eventdata,guidata(hObject))')
set(handles.popupmenuY,'callback','@(hObject,eventdata)mainGUI(''updateAxes'',hObject,eventdata,guidata(hObject))')
function setPopupmenuString(hObject, eventdata, handles)
filename = handles.filename;
[numbers, colNames] = xlsread(filename);
set(hObject,'string',colNames);
function [x,y] = readExcelColumns(filename,xCol,yCol)
a = xlsread(filename);
x = a(:,xCol);
y = a(:,yCol);
function updateAxes(hObject, eventdata, handles)
xCol = get(handles.popupmenuX,'value');
yCol = get(handles.popupmenuY,'value');
filename = handles.filename;
[x,y] = readExcelColumns(filename, xCol, yCol);
plot(handles.axes1, x,y)
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu App Building finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!