To add to the solutions, here's how to do it using the Matlab system function and the osascript terminal osascript , which runs AppleScript from the command line. The function below takes a message argument and optional title , subtitle and alert arguments. A raw input leak is also performed. The alert sound arguments can be any of the named sounds on the Sound Effects tab of the Sound panel in System Preferences, for example, 'Sosumi' .
function status=notify(msg,titl,subtitl,alert) %NOTIFY Display OS X notification message window % NOTIFY(MESSAGE,TITLE,SUBTITLE,SOUND) rep = @(str)strrep(regexprep(str,'["\\]','\\$0'),'''','\"'); cmd = ['osascript -e ''display notification "' rep(msg)]; if nargin > 1 && ischar(titl) cmd = [cmd '" with title "' rep(titl)]; if nargin > 2 && ischar(subtitl) cmd = [cmd '" subtitle "' rep(subtitl)]; if nargin > 3 && ischar(alert) && ~isempty(alert) cmd = [cmd '" sound name "' rep(alert)]; end end else cmd = [cmd '" with title "Matlab']; end status = system([cmd '"''']);
You can download a more complete version of this feature from my GitHub . Unlike terminal-notifier , I don’t believe that the notification menu icon can be changed. However, this function should work on any OS X 10.8 or 10.9 system and does not require installing or downloading any files. This code has been tested in accordance with OS X 10.9.3 and 10.11.4.
source share