Problem with plotting/updating the graph in the GUI.
Show older comments
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)
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!