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')
Verify these are printing to stderr by appending to the end of the command line command:
From GNU Octave:
octave-cli --eval "fprintf(2,'this is stderr')"
matlab -batch "fprintf(2,'this is stderr')"