Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Akbar
Akbar le 21 Juin 2018
Clôturé : Akbar le 22 Juin 2018
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 commentaires
Stephen23
Stephen23 le 21 Juin 2018
"I can't define it before, it has to be defined as it is"
Really? Why not?
Akbar
Akbar le 21 Juin 2018
All right, i tried to explain the original problem here .

Réponses (1)

Image Analyst
Image Analyst le 21 Juin 2018
Change this:
addnode = (const1 + const2)*const3;
const3 = 0.03;
to this
const3 = 0.03;
addnode = (const1 + const2)*const3;
  1 commentaire
Akbar
Akbar le 21 Juin 2018
Modifié(e) : Akbar le 21 Juin 2018
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.

Cette question est clôturée.

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by