GUI Error Message in the use of a push button and it is NOT the addition of 'guidata(hObject, handles);' that is missing

조회 수: 1 (최근 30일)
These are all of the input values for my GUI which are being converted into numbers.
rmin=str2num(get(handles.inputrmin,'String'));
thetamin=str2num(get(handles.inputthetamin,'String'));
thetamax=str2num(get(handles.inputthetamax,'String'));
BOC=str2num(get(handles.inputBOC,'String'));
OC=str2num(get(handles.inputOC,'String'));
m=str2num(get(handles.inputm,'String'));
rmax=str2num(get(handles.inputrmax,'String'));
A function is then used which calculates outputs below
opt_a, opt_b, Fmin/1000, opt_phi
These are then converted back to strings
a1=num2str(opt_a);
b1=num2str(opt_b);
Fmin1=num2str(Fmin/1000);
phi1=num2str(opt_phi);
phi1D=rad2deg(phi1);
set(handles.outputopt_a,'String',a1);
set(handles.outputopt_b,'String',b1);
set(handles.outputOptimum_Force_KN,'String',Fmin1);
set(handles.outputopt_phi,'String',phi1D);
guidata(hObject, handles);
I am getting the following error message
??? Reference to non-existent field 'outputopt_a'.
Error in ==> GUI>calculate_Callback at 371
set(handles.outputopt_a,'String',a1);
I have checked the GUI static text box which is to recieve the output and the tag is 'outputopt_a' so there is no difference here. Any idea where i have gone wrong?

채택된 답변

karan
karan 2011년 11월 25일
check calculation for opt_a...can u post the function
if opt_a is computed in a different function u need to store it in that function and get the same data to this new function where u give commands for set
  댓글 수: 2
karan
karan 2011년 11월 25일
do
handles.set_my_field = opt_a
in function where u computed
do a guidata(hObject, handles); at the end of the same function
by this you are saving the handles such that it can be used by other functions later.
no w in the function where u give commands to set your values
opt_a = handles.set_my_field
this would give u access back to the same values of opt_a in the other function where u desire it to be
David Fraser
David Fraser 2011년 11월 25일
Thanks for your quick response but after a bit of tweaking (not exactly sure what) its running fine :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Platform and License에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by