How do i use the edit text box in a GUI to change variables in a function ???

4 次查看(过去 30 天)
Hi, everyone
I'm new in Matlab and i am trying to make a GUI work like I want it too. I want to be able to change values in my function from the GUI. This is code I want to run in the GUI. e_epoch, e_show, e_LR, e_valid, e_goals are the variables I want to be able to control from the GUI.
function[net,tr]=backpropTrafo_1(e_epoch,e_show,e_LR,e_valid,e_goals);
%parameter
net.trainParam.epochs = e_epoch;
net.trainParam.show = e_show;
net.trainParam.lr = e_LR;
net.trainParam.max_fail = e_valid;
net.trainParam.goal = e_goals;
This is my GUI
I run its GUI. I put the string which is numeric into those 'edit textbox'. And then when I press pushbuttonPROSES, I want those variables that I've input on 'edit textbox' do calculate for function backpropTrafo_1. This is my code for callback function
function pushbuttonPROSES_Callback(hObject, eventdata, handles)
Data_latih=xlsread('Data_TRAFO1.xlsx','jst_trafo1','G61:K66');
Data_uji=xlsread('Data_TRAFO1.xlsx','jst_trafo1','G70:I75');
e_epoch=str2num(char(get(handles.editEpoch,'String')));
e_show=str2num(char(get(handles.editShow,'String')));
e_LR=str2num(char(get(handles.editLR,'String')));
e_valid=str2num(char(get(handles.editValid,'String')));
e_goals=str2num(char(get(handles.editGoals,'String')));
[net,tr]=backpropTrafo_1(e_epoch,e_show,e_LR,e_valid,e_goals);
When I pushed the pushbuttonPROSES in the GUI, I got back a error message that said:
Reference to a cleared variable e_epoch.
Error in backpropTrafo_1 (line 33)
net.trainParam.epochs = e_epoch;
Error in Simulasi>pushbuttonPROSES_Callback (line 214)
[net,tr]=backpropTrafo_1(e_epoch,e_show,e_LR,e_valid,e_goals);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in Simulasi (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)Simulasi('pushbuttonPROSES_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
Why do i get this error? Thanks in advance for any and all help.
  3 个评论

请先登录,再进行评论。

采纳的回答

Jan
Jan 2018-2-6
Search for the command "clear" in your code. Then find out, if it is needed there or if it destroys your data only. In the 2nd case, delete the command.

更多回答(1 个)

Ira Miranti
Ira Miranti 2018-8-4
I have the same problem. But i'm not find 'clear' in my code. What i should do?

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by