message, Code Analyzer cannot determine whether xyz is a variable or a
function, and assumes it is a function. Code analysis cannot make a
determination because xyz has no obvious value assigned to it. However, the program
might have placed the value in the workspace in a way that code analysis cannot detect.
function y=foo(x)
.
.
.
y = xyz(x);
end
For example, in the following code, xyz can be a function, or can be a variable loaded
from the MAT-file. Code analysis has no way of making a determination.
function y=foo(x)
load abc.mat
y = xyz(x);
end
Variables might also be undetected by code analysis when you use the eval, evalc,
evalin, or assignin functions.
If code analysis mistakes a variable for a function, do one of the following:
- Initialize the variable so that code analysis does not treat it as a function.
- For the load function, specify the variable name explicitly in the load command line.
For example:
function y=foo(x)
load abc.mat xyz
y = xyz(x);
end
Distinguish Structures from Handle Objects
Code analysis cannot always distinguish structures from handle objects. In the following
code, if x is a structure, you might expect a Code Analyzer message indicating that the
code never uses the updated value of the structure. If x is a handle object, however, then
this code can be correct.
function foo(x)
x.a = 3;
end
Check Code for Errors and Warnings