Clear Filters
Clear Filters

What does parse error basically mean?

276 views (last 30 days)
Maheen
Maheen on 5 Jul 2014
Commented: Image Analyst on 16 Jul 2022
I just wanted to clarify in very layman terms what is a parse error?

Answers (3)

James Tursa
James Tursa on 5 Jul 2014
When did you get this error? In general, the term "parsing" refers to MATLAB reading an m-file (script or function) and translating it into an internal code that it stores in memory. It is this "parsed" file in memory that is actually run when you execute the code.

Image Analyst
Image Analyst on 5 Jul 2014
You might have some code that throws an exception (generates an error) like this:
try
% Some code that might generate an error.
catch ME
errorMessage = sprintf('Error in function %s() at line %d.\n\nError Message:\n%s', ...
ME.stack(1).name, ME.stack(1).line, ME.message);
fprintf(1, '%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
The error here is a string in ME.message. Parse it means that you might look at the error and try to recognize certain words and take action based upon what you find. For example you might have an error that says this:
Error using imread (line 349)
File "sss.dd" does not exist.
and you might want to do some particular thing, like alert the programmer that the file doesn't exist and to make sure the folder is prepended to the filename
if ~isempty(strfind('does not exist') ) % Parse error message
warndlg(..............

Angie
Angie on 16 Jul 2022
error: parse error: syntax error >>> y3 = sin(x)cos(x); ^ error: 'y3' undefined near line 1, column 1 warning: legend: ignoring extra labels warning: called from __gnuplot_legend__ at line 490 column 13 legend at line 198 column 37
  1 Comment
Image Analyst
Image Analyst on 16 Jul 2022
You'd need a .* between sin and cos like
y3 = sin(x) .* cos(x);
Of course x also needs to be defined before that line.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!