How to call a function inside a Matlab GUI
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Image Analyst
2012년 11월 9일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!