Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Variable might be used before it's defined. How to workaround?

조회 수: 1 (최근 30일)
Akbar
Akbar 2018년 6월 21일
마감: Akbar 2018년 6월 22일
I am writing a matlab script. Code analyzer underlines one of the variables in red and says that, Variable might be used before it's defined. How to Workaround this problem? The variable is defined but only somewhere below. I can't define it before, it has to be defined as it is.
  댓글 수: 3
Stephen23
Stephen23 2018년 6월 21일
"I can't define it before, it has to be defined as it is"
Really? Why not?
Akbar
Akbar 2018년 6월 21일
All right, i tried to explain the original problem here .

답변 (1개)

Image Analyst
Image Analyst 2018년 6월 21일
Change this:
addnode = (const1 + const2)*const3;
const3 = 0.03;
to this
const3 = 0.03;
addnode = (const1 + const2)*const3;
  댓글 수: 1
Akbar
Akbar 2018년 6월 21일
편집: Akbar 2018년 6월 21일
Its not that easy. See, const3 is extracted only somewhere in the middle of some process(extracting equations). And i am talking about hundreds of variables. The process is automatic. I cannot make the process extract const3 first. I could do it manually but its time consuming.

이 질문은 마감되었습니다.

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by