How to Suppress GNU Octave Warnings

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 the warning not to appear on the screen at startup.

I know that I can suppress ALL warnings by putting this command at the top of my octave program:

 warning('off','all'); 

But this disables all warnings that are bad. How to disconnect only this?

+7
source share
3 answers

Disable warnings by warning type in GNU Octave:

See the list of warnings and their warning names in the section: '12 .2.2 Enabling and Disabling Alerts. http://www.gnu.org/software/octave/doc/interpreter/Enabling-and-Disabling-Warnings.html

Place this command in your octave program until a warning appears:

 warning('off', 'Octave:possible-matlab-short-circuit-operator'); 

Get more information about alert identifiers

After you are in the octave console, use this command so that the octave tells you about alert identifiers.

 help warning_ids 

Some warnings complete the process and cannot be suppressed; they must be fixed:

Like this:

 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. This is a software bug where two files have the same name, so the program does not know which one to use.

+9
source

To find the ID of your alert, simply enter

 [text, id] = lastwarn() 

immediately after warning. id now contains a warning identifier that you can use to disable it:

 warning('off', id) 
+4
source

Make your changes persistent in two simple steps:

  • become root
  • add a command to the file (/ usr / share / octave / site / m / startup / octaverc), which will run any Octave command at startup.

    echo "warning('off','Octave:shadowed-function')" >> /usr/share/octave/site/m/startup/octaverc

I also like to constantly download all packages:

 echo "pkg load all" >> /usr/share/octave/site/m/startup/octaverc 

Note. Follow this order, otherwise there will be warnings about the hidden function that you receive from downloading all packages.

your file should contain

 warning('off','Octave:shadowed-function') pkg load all 

Thanks to Gunther Struyf for telling us how to turn off warning alerts (see above). Link: https://wiki.archlinux.org/index.php/Octave

+3
source

All Articles