How to create global variables in a GUI m-file
조회 수: 1 (최근 30일)
이전 댓글 표시
To simplify the question, I will suppose a GUI including two buttons; button1 and button2. During the running of button1 callback the m code creates variables; some of these variables will be needed during the button2 callback. The question is: Can I create and set up global variables in a GUI m-file which could be used in all internal functions ?
댓글 수: 0
채택된 답변
Image Analyst
2012년 12월 30일
Place a line like
global myVariable1;
in every function that needs to see the variable. Functions without that line won't be able to see the variable.
For other recommended ways, see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!