how can solve this probleme ??? Undefined function or variable
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hello
how can i use the information defined in pushbutton1_Callback in the other pushbutton2_Callback without have this msg error
??? Undefined function or variable "net".
Error in ==> untitled>pushbutton2_Callback at 260
plot(net(2,:),net(3,:),'r.','MarkerSize',15);
Error in ==> gui_mainfcn at 98
feval(varargin{:});
Error in ==> untitled at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)untitled('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
0 comentarios
Respuestas (1)
Geoff Hayes
el 1 de Nov. de 2015
Editada: Geoff Hayes
el 1 de Nov. de 2015
Ali - you can easily make data available in other callbacks by using the handles structure (which is passed as the third parameter to each of your callbacks, assuming that you are using GUIDE). What you need to do is save the net data to handles in the callback for pushbutton1, and then access it from handles in the callback for pushbutton2. For example,
function pushbutton1_Callback(hObject, eventdata, handles)
% do something to get net and update the handles structure
handles.net = net;
guidata(hObject,handles); % now save the updated handles structure
Note the use of guidata which is important in saving the updated handles structure. Now, in your second callback access net as
function pushbutton2_Callback(hObject, eventdata, handles)
if isfield(handles,'net')
plot(handles.net(2,:),handles.net(3,:),'r.','MarkerSize',15);
end
And that is it. The isfield is used above to make sure that the net exists in handles before we try to access it.
2 comentarios
Geoff Hayes
el 1 de Nov. de 2015
ali's answer moved here
thank you so much i will try it and tell you the ressult
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!