How to call a function inside a Matlab GUI
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
function PushMe_Callback(hObject, eventdata, handles)
set(handles.output_line,'String','I Got here');
Get_Length(Note_Vector,output,Counter,Total_num)
%------------------------------------------------------------
function Get_Length(Note_Vector,output,Counter,Total_num)
output = [ ];
while (1)
T = Total_num - Counter;
for j=1:T
[xml_input]=Get_Note(Note_Vector(j));
output = [output xml_input];
end
end
5 comentarios
Milos
el 9 de Nov. de 2012
Are the variables Note_Vector,output,Counter,Total_num in the GUI workspace?
Respuestas (1)
Image Analyst
el 9 de Nov. de 2012
Well apparently Note_Vector is not in scope inside the PushMe_Callback() function so that when PushMe_Callback() goes to call Get_Length(Note_Vector,output,Counter,Total_num) it does not know what Note_Vector is. And it probably doesn't know what output,Counter,Total_num are either. When you set a breakpoint there, and then type in those variables into the command window, what does it say? Or you can look in the workspace panel to see the variables that are in the local workspace of your PushMe_Callback() function. Actually this is all just basic debugging - do you know how to debug: set breakpoints, examine variables, step through code, etc.? Also are you aware of scope, which means that every function has its own private set of variables and that a function won't see any other functions variables unless you take special care to make it see them. All functions don't automatically see every other functions internal variables. So if you defined Note_Vector somewhere, like in the OpeningFcn() function where you put startup code, it doesn't mean that every callback function in your m-file will automatically see those variables internal to OpeningFcn. A custom function you wrote won't even see variables you attach to the handles structure unless you pass the handles structure into your custom function. And you better pass it back out if you make any changes to it or those changes will be lost once the function exits. Why don't you check out the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!