Matlab: display full error path -


consider following foo.m file:

try     disp(r3) catch me     disp(getreport(me)) end 

when run with:

matlab -nodisplay -nodesktop -nosplash -nojvm -wait -r "run('foo.m')" 

i get:

undefined function or variable 'r3'.  error in foo (line 2)     disp(r3)  error in run (line 96) evalin('caller', [script ';']); 

i wondering if possible display full path of files referenced in errors. know can use which and, instance, get:

» run c:\prog-lang\matlab\toolbox\matlab\lang\run.m 

but errors directly displayed like

error in c:\prog-lang\matlab\toolbox\matlab\lang\run.m (line 96) 

rather than

error in run (line 96) 

one option hack error report returned getreport, example using function search , replace each instance of "foo" full path file -

function msg = getreportfull(e)      stack = dbstack();     stack(1) = [];      msg = getreport(e);      = 1:length(stack)         fname = stack(i).name;         fpath = which(stack(i).file);         msg = strrep(msg, ['>' fname '<'], ['>' fpath '<']);     end  end 

then following code in "foo.m" -

try     disp(r3); catch e     disp(getreportfull(e)); end 

you observe error -

>> run('foo.m') undefined function or variable 'r3'.  error in c:\foo.m (line 2)     disp(r3);  error in c:\program files\matlab\r2012b\toolbox\matlab\lang\run.m (line 64) evalin('caller', [script ';']); 

this absolutely untested hack, , make no guarantees won't break @ inopportune moment.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -