1function line_error(caller, msg)
2%LINE_ERROR Display a plain-text error message with file and line info.
4% LINE_ERROR(CALLER, MSG)
throws an error with CALLER
's name and message,
5% including the source file and line number, in plain text (no hyperlink).
7% Copyright (c) 2012-2026, Imperial College London
11 msg = strrep(msg, '\n
', ''); % Strip out literal '\n
' if present
15 lineNum = stack(2).line;
20 filePath = which(caller);
25 errStr = sprintf('[%s.m @ line %d] %s
', caller, lineNum, msg);