A call to error
appears to use
sprintf
to construct the error message. Because you can
call error
in numerous ways (with or without error tags,
with or without formats and extra arguments, and so on), sometimes Code Analyzer
mistakenly produces this message when you use sprintf
to
produce an error tag or use it as an argument to an existing format
specifier.
Remove the sprintf
call and pass the format specifier and arguments
directly to the error
function. For example, replace code such as
this:
error('prog:input', ...
sprintf('Cannot open %s because %s\n', ...
filename, reason));
with this code:
error('prog:input', ...
'Cannot open %s because %s\n', ...
filename, reason);
Note that MATLAB converts special characters (such as \n
,
\t
, %s
, and %d
) in
the error message only when you specify more than one input argument with
error
.
If Code Analyzer produced this message erroneously, you can suppress it, as described in Adjust Code Analyzer Message Indicators and Messages.