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

조회 수: 8 (최근 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
Febrian Dhimas Syahfitra
Febrian Dhimas Syahfitra 2018년 2월 6일
I don't know sir. So, what am I supposed to do ? Please, help me sir
Febrian Dhimas Syahfitra
Febrian Dhimas Syahfitra 2018년 2월 9일
Oh I see. Yeah I found 'clear' in my code. Thank you so much sir

댓글을 달려면 로그인하십시오.

채택된 답변

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에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by