views:

57

answers:

2

Lets say someone made a Matlab GUI using GUIDE. Now I want to use that code in a programmatic environment - that is no human-in-the-loop. What's the easiest way for me to "script" the human interactions with the GUI so as to manipulate the various controls in the appropriate sequence to make the tool crunch my numbers and get its results? I'm looking for a non-invasive way to reuse the capabilities of this tool. My ideal programmatic environment for invoking the Matlab functionality would be Java.

I can open up the GUIDE .fig and trace out all the callback functions on the various controls, but the design pattern seems to be to shove all the data into the handles variable.

I've got the ability to use the Matlab Builder JA for Java to generate java classes, if that is helpful in any way. Any suggestions would be appreciated.

+1  A: 

Extract form the following post. Use

guiname('pushbutton', object, eventdata, handles)

to call callbacks in 'guiname'.

Have you considered using a MVC pattern. Extracting the 'model' from your GUI might leave you with reusable code.

zellus
+3  A: 

MTALAB GUI is Java GUI. For the GUI automation there is a recent post on the blog of Yair Altman: http://undocumentedmatlab.com/blog/gui-automation-robot/

Following applies only if you can rewrite the application.

There is usually no need for any form of GUI automation for such tasks as yours. Application should have following architecture: Model->Business Logic->GUI. Each layer is decoupled from layers above it - Model knows nothing about Business Logic which knows nothing about the GUI. It is then possible to call Business Logic programmatically without even displaying the GUI. Here is an example for MVC implementation in MATLAB.

For this reason GUIDE should be avoided. There is an undocumented layout manager in MATLAB, there are also some on the file exchange.

In your case you could put the whole Business Logic outside the GUI Logic making GUIDE callbacks do nothing but call your Business Logic functions.

Mikhail
+1 perfect answer, should be used for **testing purposes only**, as you mention.
zellus