Undefined function or variable ... Error while evaluating uicontrol Callback

조회 수: 6 (최근 30일)
Hamid
Hamid 2015년 12월 2일
댓글: Hamid 2015년 12월 2일
Hi everyone, I'm using GUI tool.
I'm going to enter my inputs from menu but I got this error :
??? Undefined function or variable 'I'.
Error in ==> GUI_2>Calculate_Callback at 379
A=I/sqrt(((TCAP*10^-4)/(tc*ar*pr))*log((k0+Tm)/(k0+Ta)));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> GUI_2 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)GUI_2('Calculate_Callback',hObject,eventdata,guidata(hObject))
??? Error using ==> drawnow
Error while evaluating uicontrol Callback
this is my code (short version) :
...
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
prompt = {'rms symmetrical line to ground fault current in kA:'};
title = 'Ground Grid Inputs';
lines = 0.8;
def = {''};
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
answer=str2double(inputdlg(prompt,title,lines,def,options));
I=answer(1);
...
% --- Executes on button press in Calculate.
function Calculate_Callback(hObject, eventdata, handles)
A=I/sqrt(((TCAP*10^-4)/(tc*ar*pr))*log((k0+Tm)/(k0+Ta)));
WHAT SHOULD I DO??
pleaseeeeeeeeeee
  댓글 수: 4
Adam
Adam 2015년 12월 2일
The workspace for Untitled_1_Callback is completely separate from the workspace of Calculate_Callback. This is why when you asked this question previously with a lot of the key code missed out it did not make sense why 'I' should be undefined when you use it.
Hamid
Hamid 2015년 12월 2일
Ok, I will check that documents in other time.
Thanks.

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

채택된 답변

Adam
Adam 2015년 12월 2일
handles.I = answer(1);
guidata( hObject, handles );
in your first callback and
I = handles.I;
at the start of your second callback will fix this in a simple way, but I strongly advise you to read up on this, following the links Stephen suggested. Using guidata is very easy when you are used to it and actually understand it, but it also has pitfalls if you simply copy examples of it without properly understanding what it is doing and why.

추가 답변 (0개)

카테고리

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