What does parse error basically mean?
426 次查看(过去 30 天)
显示 更早的评论
I just wanted to clarify in very layman terms what is a parse error?
0 个评论
回答(3 个)
James Tursa
2014-7-5
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.
0 个评论
Image Analyst
2014-7-5
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(..............
0 个评论
Angie
2022-7-16
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 个评论
Image Analyst
2022-7-16
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!