File Exchange

image thumbnail

Printing MATLAB errors (R14sp3 and later)

version 1.2.0.1 (1.51 KB) by Malcolm Wood
Produces formatted output from the information returned by "lasterror"

2 Downloads

Updated 01 Sep 2016

View Version History

View License

Following the long-awaited addition to MATLAB of a mechanism for retrieving the call stack at the time of the last error it is now possible to find out where in the code the error occurred even when an error has been caught by a "catch" statement.
However, the convenient hyperlinks which allow you to go directly to the source of the error are only available when the error is uncaught.

This function prints similar hyperlinks in the MATLAB command window even for errors which were caught. Simply type "ple" at any time, and details of the the last error, including hyperlinks to every point in the call stack, will be shown in the command window.

Cite As

Malcolm Wood (2021). Printing MATLAB errors (R14sp3 and later) (https://www.mathworks.com/matlabcentral/fileexchange/9525-printing-matlab-errors-r14sp3-and-later), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Kent Schonert

I use this quite a bit. I modified it to remove markups when the application is deployed so the errors are more readable on the MCR's dos window.

if isdeployed
href = sprintf('''%s'',%d',ff,e.line);
else
href = sprintf('matlab:opentoline(''%s'',%d)',ff,e.line);
end

if strcmp(command,n)
% main function in this file
if isdeployed
fprintf(1,' %s\n',href);
else
fprintf(1,' <a href="%s">%s,%d</a>\n',href,ff,e.line);
end
else
% subfunction in this file
if isdeployed
fprintf(1,' %s >%s,%d\n',href,n,e.line);
else
fprintf(1,' <a href="%s">%s >%s,%d</a>\n',href,ff,n,e.line);
end
end

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: SeisLab 2.01, SeisLab 3.01

Community Treasure Hunt

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

Start Hunting!