I am using Octave version 3.4.3, and I get this warning:
warning: fmincg.m: possible Matlab-style short-circut operator at line 104, column 20
I know why this warning occurs, I just want to make the warning not appear on screen when run.
I know I can suppress ALL warnings by putting this command at the top of my octave program:
warning('off','all');
Docs: https://octave.sourceforge.io/octave/function/warning.html
But that disables all warnings which is bad form. How to disable only this one?
Advertisement
Answer
Disable warnings by warning type in GNU Octave:
See the list of warnings and their warning id’s and names here in section: ‘12.2.2 Enabling and Disabling Warnings’. https://octave.sourceforge.io/octave/function/warning_ids.html
The warning names and id’s are listed with octave command:
help warning_ids
Put this command in your octave program before the warning occurs:
warning('off', 'Octave:possible-matlab-short-circuit-operator');
or disable all warnings with
warning('off', 'all');
Note: If your warning is thrown by the octave interpreter itself before your script is run, then you’ll have to take a different approach. For example use octave yourfile.m 2>/dev/null
which also has the unfortunate side effect of redirecting the stderr of both the octave engine and your script.
Certain warnings terminate the process, and can’t be suppressed, they must be remedied:
Like this one:
warning: function /home/el/octave/multicore-0.2.15/gethostname.m shadows a built-in function
To fix this, rename /home/el/octave/multicore-0.2.15/gethostname.m to /home/el/octave/multicore-0.2.15/gethostname_backup.m. And the warning goes away. It’s a bug in the software where two files have the same name, so the program doesn’t know which one to use.