Variable might be used before it's defined. How to workaround?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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 Comments
Adam
on 21 Jun 2018
Well you haven't shown any code so how could we possibly guess. If you are using the variable then obviously it needs to exist at that point unless you are assigning to it for the first time, in which case it will be created there and then. without the code though it is all just speculation.
Stephen23
on 21 Jun 2018
Akbar
on 21 Jun 2018
Answers (1)
Image Analyst
on 21 Jun 2018
Change this:
addnode = (const1 + const2)*const3;
const3 = 0.03;
to this
const3 = 0.03;
addnode = (const1 + const2)*const3;
1 Comment
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!