Error invalid handle after PLOT when I change ratiobutton
Ältere Kommentare anzeigen
When I change of ratiobutton after PLOT I receive this error:
??? Error using ==> set
Invalid handle
Error in ==> Directividad>Eje_abscisas_SelectionChangeFcn at 176
set([handles.edit_b1 handles.edit_a handles.edit_p1 handles.text1 handles.text2
handles.text3],'Visible','on');
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Directividad at 17
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Directividad('Eje_abscisas_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))
Error in ==> hgfeval at 63
feval(fcn{1},varargin{:},fcn{2:end});
Error in ==> uitools.uibuttongroup.childAddedCbk>manageButtons at 80
hgfeval(cbk, source, evdata);
??? Error while evaluating uicontrol Callback
I think the problem is one of this functions.
Functions of buttongroup and ratiobuttons:
function Eje_abscisas_SelectionChangeFcn(hObject, eventdata, handles)
set([handles.edit_b1 handles.edit_a handles.edit_p1 handles.text1 handles.text2 handles.text3],'Visible','on');
global SELECCION;
handles.edit_a
switch get(eventdata.NewValue,'Tag')
case 'button_a'
set(handles.edit_a,'Visible','off');
set(handles.text1,'Visible','off');
SELECCION=1;
case 'button_b1'
set(handles.edit_b1,'Visible','off');
set(handles.text2,'Visible','off');
SELECCION=2;
case 'button_p1'
set(handles.edit_p1,'Visible','off');
set(handles.text3,'Visible','off');
SELECCION=3;
end
Function of pushbutton:
function PLOT_Callback(hObject, eventdata, handles)
global SELECCION;
if SELECCION == 1
p1=handles.edit_p1;
b1=handles.edit_b1;
mx = handles.mx;
a = linspace(0,mx,1000);
termino_Fresnel = b1./(sqrt(2*p1));
C = mfun('FresnelC',termino_Fresnel);
S = mfun('FresnelS',termino_Fresnel);
directividad = ((64.*a.*p1)./(pi.*b1)).*(C.^2+S.^2);
axes(handles.axes1);
handles.x=a;
handles.h=plot(a,directividad);
elseif SELECCION == 2
p1=handles.edit_p1;
mx=handles.mx;
a=handles.edit_a;
b1 = linspace(0,mx,1000);
termino_Fresnel = b1./(sqrt(2*p1));
C = mfun('FresnelC',termino_Fresnel);
S = mfun('FresnelS',termino_Fresnel);
directividad = ((64.*a.*p1)./(pi.*b1)).*(C.^2+S.^2);
axes(handles.axes1);
handles.x=b1;
handles.h=plot(b1,directividad);
elseif SELECCION == 3
mx=handles.mx;
p1=linspace(0,mx,1000);
a=handles.edit_a;
b1 = handles.edit_b1;
termino_Fresnel = b1./(sqrt(2*p1));
C = mfun('FresnelC',termino_Fresnel);
S = mfun('FresnelS',termino_Fresnel);
directividad = ((64.*a.*p1)./(pi.*b1)).*(C.^2+S.^2);
axes(handles.axes1);
handles.x=p1;
handles.h=plot(p1,directividad);
end
The source code and and .fig file is upload on:
Please, Can anyone help me? Thank you, Luis
Antworten (1)
Paulo Silva
am 4 Jun. 2011
You forgot to update the handles structure in the plot_callback, add the code in the end of the plot_callback:
guidata(hObject,handles);
It takes time to draw the graph so you should consider adding a waitbar or just disable (or hide) the plot button after someone press until the graph is drawn.
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!