Is it possible to send a notification from Matlab to the Notification Centre in OSX?

macos, matlab, notifications

Solution

Here's a complete function. It shows Matlab as the name and icon, and clicking on the notification will bring you to Matlab:

function notify(message)
  escaped_message = strrep(message, '"', '\"');
  [~, ~] = system(['/usr/local/bin/terminal-notifier ' ...
                   '-title Matlab ' ...
                   '-group com.mathworks.matlab ' ...
                   '-activate com.mathworks.matlab ' ...
                   '-sender com.mathworks.matlab ' ...
                   '-message "' escaped_message '"']);
end

Problem

I want to send a notification when my Matlab code is finished running to the Notification Centre. I'm on Mountain Lion 10.8.3 and have Matlab 2012b. Is this possible? If so, how?

Original source