In both Matlab and GNU Octave, functions like
warning by default print messages to
stderr in non-interactive sessions, for easier capture to uncluttered log files.
To print to stderr in general, use
fprintf(2, 'my text')
You can verify these are printing to stderr by appending to the end of the command line command:
octave-cli --eval "fprintf(2,'this is stderr')"
matlab -batch "fprintf(2,'this is stderr')"