Guide data isn't updating the "handles" variable

I'll appreciate so much any help, please. I build a GUI with a simple idea: there is a button where the user can load a data set and another button where a logic is applyed above that data. This last logic generate a result that has to be threw out from the GUI, before it closed.
I mean, the "train_Callback" function generate a result and I record that result in handles. At the end of the function you can see the call "guidata(hObject, handles);", but when I try to use that at "training_center_OutputFcn" it doesn't exist!
Someone can help me?
This is the code:
function varargout = training_center(varargin)
% TRAINING_CENTER MATLAB code for training_center.fig
% TRAINING_CENTER, by itself, creates a new TRAINING_CENTER or raises the existing
% singleton*.
%
% H = TRAINING_CENTER returns the handle to a new TRAINING_CENTER or the handle to
% the existing singleton*.
%
% TRAINING_CENTER('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TRAINING_CENTER.M with the given input arguments.
%
% TRAINING_CENTER('Property','Value',...) creates a new TRAINING_CENTER or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before training_center_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to training_center_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 training_center
% Last Modified by GUIDE v2.5 25-Jul-2012 22:20:48
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @training_center_OpeningFcn, ...
'gui_OutputFcn', @training_center_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 training_center is made visible.
function training_center_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 training_center (see VARARGIN)
% Choose default command line output for training_center
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes training_center wait for user response (see UIRESUME)
%uiwait(handles.figure1);
% --- Executes on button press in loadDataSet.
function loadDataSet_Callback(hObject, eventdata, handles)
% hObject handle to loadDataSet (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.trainTheNeuralNetwork = true;
[fileName, pathToFile] = uigetfile('*.m', 'Opening an training data set');
if ~isequal(fileName,0) && ~isequal(pathToFile,0)
handles.currentTrainingDataSet = importdata([pathToFile fileName]);
% Save information about actual file
handles.currentFile.fileName = fileName;
handles.currentFile.pathToFile = pathToFile;
% Controls in GUI and Flags
set(handles.train,'enable','on');
set(handles.statusLabel,'string',[fileName ' training data set was loaded. Now, press "Train".']);
end
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in train.
function train_Callback(hObject, eventdata, handles)
% hObject handle to train (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Horizontal Neural Network
% Create the neural network
% log
%disp('creating horizontal neural network');
horizontalNet = timedelaynet(1:2,120);
horizontalNet.numInputs = 1;
horizontalNet.numLayers = 2;
horizontalNet.inputs{1}.size = 320;
horizontalNet.layers{2}.size = 1;
% Connect the neural network
horizontalNet.inputConnect(1) = 1;
horizontalNet.layerConnect(2,1) = 1;
horizontalNet.outputConnect(2) = 1;
% Determine the transfer functions
horizontalNet.layers{1}.transferFcn = 'logsig';
horizontalNet.layers{2}.transferFcn = 'logsig';
% Bias
horizontalNet.biasConnect = [1 ; 1];
% Initializations
horizontalNet.layers{1}.initFcn = 'initnw';
horizontalNet.layers{2}.initFcn = 'initnw';
% Performance function
horizontalNet.performFcn = 'mae';
% Training parameters
horizontalNet.trainFcn = 'traingdm';
horizontalNet.trainParam.lr = 0.1;
horizontalNet.trainParam.mc = 0.9;
% Training the neural network
%horizontalNet = train(horizontalNet,);
% Vertical Neural Network
% Create the neural network
% log
%disp('creating vertical neural network');
verticalNet = timedelaynet(1:2,160);
verticalNet.numInputs = 1;
verticalNet.numLayers = 2;
verticalNet.inputs{1}.size = 240;
verticalNet.layers{2}.size = 1;
% Connect the neural network
verticalNet.inputConnect(1) = 1;
verticalNet.layerConnect(2,1) = 1;
verticalNet.outputConnect(2) = 1;
% Determine the transfer functions
verticalNet.layers{1}.transferFcn = 'logsig';
verticalNet.layers{2}.transferFcn = 'logsig';
% Bias
verticalNet.biasConnect = [1 ; 1];
% Initializations
verticalNet.layers{1}.initFcn = 'initnw';
verticalNet.layers{2}.initFcn = 'initnw';
% Performance function
verticalNet.performFcn = 'mae';
% Training parameters
verticalNet.trainFcn = 'traingdm';
verticalNet.trainParam.lr = 0.1;
verticalNet.trainParam.mc = 0.9;
% Output the neural network
handles.nnOutput = {horizontalNet, verticalNet};
% Update handles structure
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = training_center_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)
% Controls in GUI and Flags
%set(handles.train,'enable','off');
%set(handles.statusLabel,'string','The neural network was trained successfully');
% Get default command line output from handles structure
if isfield(handles,'nnOutput')
varargout{1} = handles.nnOutput;
else
varargout{1} = hObject;
end

Réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by