1function line_warning(caller, MSG, varargin)
2% LINE_WARNING(CALLER, ERRMSG)
4% Copyright (c) 2012-2026, Imperial College London
7%global GlobalConstants.Verbose
9persistent suppressedWarnings;
10persistent suppressedWarningsTic;
11persistent lastWarningTime;
12persistent suppressedAnnouncement;
14if GlobalConstants.Verbose == VerboseLevel.SILENT
18suppressedAnnouncement =
false;
19errmsg=sprintf(MSG, varargin{:});
20w = warning(
'QUERY',
'ALL');
21w(1).state =
'on'; % always print warnings by
default
24 %warning(
'[%s] %s',caller,MSG);
25 finalmsg = sprintf(
'Warning [%s.m]: %s',caller,errmsg);
27 if ~strcmp(finalmsg, lastWarning) || (toc(suppressedWarningsTic)-toc(lastWarningTime))>60
28 line_printf(finalmsg);
30 lastWarning = finalmsg;
31 suppressedWarnings =
false;
32 suppressedWarningsTic = tic;
34 if ~suppressedWarnings && ~suppressedAnnouncement
35 %line_printf(finalmsg);
37 finalmsg = sprintf(
'\nWarning [%s.m]: %s',caller,errmsg);
38 line_printf(sprintf(
'Warning [%s.m]: %s',caller,
'Warning message casted more than once, repetitions will not be printed on screen for 60 seconds.\n'));
39 %warning(sprintf(
'Warning [%s.m]: %s',caller,
'Warning message casted more than once, repetitions will not be printed on screen for 60 seconds.'));
40 suppressedAnnouncement =
true;
41 suppressedWarnings =
true;
42 suppressedWarningsTic = tic;
48 case 'MATLAB:toc:callTicFirstNoInputs'
50 line_printf(finalmsg);
51 lastWarning = finalmsg;
52 suppressedWarnings =
false;
53 suppressedWarningsTic = -1;
58 %line_printf(sprintf(
'Warning [%s.m]: %s',caller,errmsg));