Struct contents reference from a non-struct array object. again

12 views (last 30 days)
I think this problem is very common and MATLAB may be better to make some modifications in order that a user can avoid it in the future. I can't figure it out. It has been taking all of my time. Please, help me.
This is the code
function varargout = AAN__GUI(varargin)
% AAN__GUI MATLAB code for AAN__GUI.fig
% AAN__GUI, by itself, creates a new AAN__GUI or raises the existing
% singleton*.
%
% H = AAN__GUI returns the handle to a new AAN__GUI or the handle to
% the existing singleton*.
%
% AAN__GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in AAN__GUI.M with the given input arguments.
%
% AAN__GUI('Property','Value',...) creates a new AAN__GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before AAN__GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to AAN__GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help AAN__GUI
% Last Modified by GUIDE v2.5 17-Sep-2017 02:13:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @AAN__GUI_OpeningFcn, ...
'gui_OutputFcn', @AAN__GUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before AAN__GUI is made visible.
function AAN__GUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to AAN__GUI (see VARARGIN)
% Choose default command line output for AAN__GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes AAN__GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = AAN__GUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function nodes_per_h_layer_Callback(hObject, eventdata, handles)
% hObject handle to nodes_per_h_layer (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of nodes_per_h_layer as text
% str2double(get(hObject,'String')) returns contents of nodes_per_h_layer as a double
% --- Executes during object creation, after setting all properties.
function nodes_per_h_layer_CreateFcn(hObject, eventdata, handles)
% hObject handle to nodes_per_h_layer (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in Run.
function Run_Callback(hObject, eventdata, handles)
% hObject handle to Run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[new_weights err] =retrain_fun(str2double(get((handles.nodes_per_h_layer),'String')),...
10^-5,.900,6,4,50,[0,1,1,0;0,1,0,1],[1 1 0 0],1);
and this is the whole error message
Struct contents reference from a non-struct array object.
Error in AAN__GUI>Run_Callback (line 106)
[new_weights err] =retrain_fun(str2double(get((handles.nodes_per_h_layer),'String')),...
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in AAN__GUI (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)AAN__GUI('Run_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
  3 Comments
Walter Roberson
Walter Roberson on 17 Sep 2017
Edited: Walter Roberson on 17 Sep 2017
Did you attempt to run this by double-clicking on the .fig file? You need to run it by invoking the .m file.
OCDER
OCDER on 18 Sep 2017
Edited: OCDER on 18 Sep 2017
I think Walter figured it out - I get the same error if I double click the .fig file. On the other hand, running AAN__GUI.m works fine (until the missing function). Double clicking the .fig skips both the creation of handles and also the OpeningFcn, hence there's no handles for you to use.

Sign in to comment.

Answers (1)

OCDER
OCDER on 18 Sep 2017
Double clicking the .fig to open the GUI skips both the creation of handles and also the OpeningFcn, hence there's no handles for you to use. Calling your GUI by the mfile name instead should work.
>> AAN__GUI

Categories

Find more on Creating, Deleting, and Querying Graphics Objects 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!