I am new to Matlab GUIs. I'm having a strange problem. When running the GUI code from the matlab code editor (clicking the run button), everything runs fine. However, when I double click the file from matlab (file browser on the left) I get an error.
Here's what Matlab says:
Attempt to reference field of non-structure array.
Error in GUI>scanButton_Callback (line 81) axes(handles.axes1);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in GUI (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)GUI('scanButton_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I am trying to plot a graph that is created by the 'main' script in 'axes1' in the GUI. The only change I've made in the GUI code is:
% --- Executes on button press in scanButton.
function scanButton_Callback(hObject, eventdata, handles)
% hObject handle to scanButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1);
main();
The code in the 'main' script that creates the plot is:
[x, y, z] = meshgrid(1:cSecDim, 1:cSecDim, 1:numSec);
scatter3(x(:),y(:),z(:),30,fullShape(:), 'fill');
I am sure there is a simple answer as to why the error is occurring. Please forgive my ignorance.