1
votes

I would like to open a Matlab/Simulink file from a GUI (Java/Eclipse), select a certain block within the simulink model, and somehow get back the path of that block.

I know how to implement a Browse button in the GUI to select the file, but I need some hints to go on: how to automatically open the selected file with Matlab/Simulink, and how to proceed to get back the "path" of the block within the system architecture. I need that path as an input for a further task.

EDIT. To open the file, it is necessary to implement an JButton for browsing, and then:

Desktop.getDesktop().open(file);
1

1 Answers

0
votes

First, you may use AutoIt to do the following automatically.

1) open a Matlab session 2) uiopen your Simulink model 3) wait for user to select a block and return current block path 4) save the string from gcb command in Matlab to an AutoIt var.

Then, build the AutoIt script to an exe, and in your Java GUI button listerner invoke that execute file, for example:

private static ActionListener onPress = new ActionListener(){
    @Override public void actionPerformed(ActionEvent e) {
        try {
            Runtime.getRuntime().exec("cmd /c yourAutoItScript.exe");
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
};  

Note that though AutoIt is Free, it works only on Windows.