Matlab & Applescript?
By CRP at Mon, Nov 16 2009 11:03am |
Does anyone know if Matlab for OSX has an applescript dictionnary? It would be useful to "remote control" Matlab from other apps like OpenOffice, Office for Mac or Numbers.
Thanks
Chris



I don't think so
Unless it's improved in R2009, the Mac OS X version of MATLAB was a barely-tweaked version of MATLAB for Linux (which is why the menu bar doesn't work).
Won't work
I tried it up to R2009a and even trying to script in via "System Events" doesn't work. That gives a "connection lost" message...
Mathworks should really get their act together on the Mac platform. However I'd like the performance issues to be solved first...
Cheers,
Dirkjan
This is a very good idea
Supporting AppleScript in MATLAB is a very good idea, but MATLAB can be scripted to do just about anything already, through the 'matlab -r' shell command. From AppleScript, you could use "do shell script..." to call MATLAB and send it commands. The full MATLAB language is available; you can do anything. You can also execute AppleScript from MATLAB by escaping out to the shell, and calling osascript, '!osascript...'.
We have given AppleScript dictionary support a great deal of thought, and the main issue is that we have a lot of other ground to cover to enable MATLAB to fit in better on the Mac platform, and AppleScript falls low on the list of priorities. Also, it would take a very long time to create the kind of dictionary that would encompass everything that MATLAB can do, and develop it to a point where it is mature. In the face of an existing and comprehensive alternative (shell scripting and the MATLAB language), it's a tough sell.
I'm not trying to play down the desire or the value of AppleScript, I'm a huge fan of it. I speak from experience: I was the primary developer who added AppleScript scripting and recording support to Media 100's video editing system. It took more than a year just to get a basic dictionary working, and another two years to develop that to a point where an organization like ShowTime Networks could rely upon it for daily automation. And The MathWorks' product code base is a lot bigger.
So, I think it would take a very long time, for marginal benefit over what you can already do today, and I'm sure I can drum up plenty of agreement that we have bigger fish to fry to improve MATLAB on the Mac platform.
Applescript and UNIX
There are a couple of tutorials on this site that provide an introduction to applescript and UNIX.
e.g.
http://www.macresearch.org/tutorial_applescript_for_scientists_part_ii
I also gave a lecture, slides here
http://homepage.mac.com/swain/Sites/Macinchem/Applescript/lecture/applescript_unix.html
For this sort of application I think it is a very attractive option.
BTW, what solutions are
BTW, what solutions are available for sharing data with other applications in Matlab? I know about COM in windows, is there something similar in Linux and OsX?