Its a simple gui that selects an excel file and you are able to plot different variables of data vs each other. I am able to select the excel file and the dropdown boxes become populated with variables, but when i click which variable i want, it doesn't plot it and in the command window this pops up: ans = @(hObject,eventdata)MainGUI('updateAxes',hObject,eventdata,guidata(hObject))
this is my code, i believe its something with the callback.
% --- Executes on button press in pushbuttonLoadXLS.
function pushbuttonLoadXLS_Callback(hObject, eventdata, handles)% hObject handle to pushbuttonLoadXLS (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.fileName = uigetfile('*.xls');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))')set(handles.radiobuttonRaw,'callback','@(hObject,eventdata)MainGUI(''updateAxes'',hObject,eventdata,guidata(hObject))')set(handles.radiobuttonNormalized,'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,xColNum,yColNum)a = xlsread(fileName);x = a(:,xColNum); % make time be x axis for data
y = a(:,yColNum); % put data in y axis
function updateAxes(hObject,eventdata,handles)xColNum = get(handles.popupmenuX,'value');yColNum = get(handles.popupmenuY,'value');fileName = handles.fileName;[x,y] = readExcelColumns(fileName,xColNum,yColNum);flagWantsNormalized = ... get(handles.radiobuttonNormalized,'value');if flagWantsNormalized y = (y - min(y)) / range(y);endplot(handles.axes1,x,y)
Best Answer