How to make 'blue' variable?

조회 수: 9 (최근 30일)
Mikhail
Mikhail 2014년 9월 12일
댓글: Mikhail 2014년 9월 15일
Hi all, I'm trying to make my own ImageViewer. Using some program as a template, I saw a lot of 'blue' variables in it (when I point on such variable there is a text "The scope of variable ... spans multiple function").
Now I understood, that I want to use such variables also - in callback functions to update text, data, and so on.
How can I create such variables? Short explanation of what does it mean is appreciated as well. Thanks.

채택된 답변

Image Analyst
Image Analyst 2014년 9월 12일
Keywords are in pure blue. Global variables are in cyan. You can just put the line
global myVariable;
in any function that needs to see the global variable. Other than that, just create it and use it like any other variable.
  댓글 수: 2
Mikhail
Mikhail 2014년 9월 15일
But in that template there is only one variable defined as global. However there arre a lot of global variables. When I am trying to do that in my program, my callback function doesn't use it as global
Image Analyst
Image Analyst 2014년 9월 15일
Post a screenshot of your screen so we can see it. In nwindows type alt-PrintScreen, then go to http://snag.gy and paste it in and give us the url or click on the green and brown image icon to paste it in your response here.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mikhail
Mikhail 2014년 9월 15일
Look! only 1 global variable is defined, however you can see a lot of cyan variables.
  댓글 수: 1
Mikhail
Mikhail 2014년 9월 15일
Got it, in that template he just wrote callback function inside main function. Therefore variables which he used in both main and callback function automatically became cyan. Thanks

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by