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

1 Ansicht (letzte 30 Tage)
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?

Akzeptierte Antwort

karan
karan am 25 Nov. 2011
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 Kommentare
karan
karan am 25 Nov. 2011
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 am 25 Nov. 2011
Thanks for your quick response but after a bit of tweaking (not exactly sure what) its running fine :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by