Code Analyzer returns this message because it appears the code accesses the
value of the named variable before it sets that variable. Sometimes, this
message results from an error in the code logic or a typographical error. Other
times, Code Analyzer generates this message incorrectly because MATLAB has
functions, such as load
and eval
, which can set new
variables in the workspace without Code Analyzer detecting it.
This message is incorrect more often than most messages. However, when it is correct, this message reveals problems that might otherwise cause obscure run-time bugs in your program.
If Code Analyzer generated this message as the result of an error in the code, fix the error. Otherwise, if Code Analyzer generated this message incorrectly, do one or more of the following:
Give Code Analyzer (and anyone else reading the program) more information about where the variable gets set.
For example, sometimes initializing the variable can remove the message.
Be explicit about which variables are loaded through a load
command.
Simplify complicated program logic for the benefit of both Code Analyzer and human readers of the program.
Suppress the message as described in Adjust Code Analyzer Message Indicators and Messages.