global variable not always global

I am relatively new to Matlab. Sometimes when I declare a variable as global its value does not carry to all functions. I list the variable in the 'global' section at the top of each function. I see the variable in the global section of each function, but the code does not see it that way. When I highlight that variable all other instances of it are highlighted in the function. But the same variable is not highlighted in other functions. It is not incorrect spelling or capitalization - I have copied and pasted. I know I have sometimes I declared a variable global more than once in a function and then deleted the duplicates.
My question is once I've made this mess how do I correct it so the code works.
Thanks for your help with the elementary question.
Jim

댓글 수: 3

the cyclist
the cyclist 2011년 9월 22일
It is difficult to diagnose this situation without seeing any code. Are you able to provide an example that illustrates the problem you are having?
TAB
TAB 2011년 9월 22일
It will be better if you can share the section of your code.
Walter Roberson
Walter Roberson 2011년 9월 22일
I would not expect the MATLAB editor to highlight copies of the variable in other functions.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

태그

질문:

Jim
2011년 9월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by