How can I invoke a Java window from an mdl file?

1 Ansicht (letzte 30 Tage)
Nick
Nick am 21 Jul. 2012
I've created a block that looks like this in my mdl file:
Block {
BlockType "S-Function"
Name "FileReader"
...
MaskPromptString "File Name|Output Port Type|Hex|Round|Comment"
MaskStyleString "edit,popup(int|uint|dint|duint|fixed point|"
"dfixed point),checkbox,checkbox,edit"
...
Rather than enter a file name in an editable text field, I want to invoke a Java JFileChooser. Is this possible?

Antworten (1)

Kaustubha Govind
Kaustubha Govind am 25 Jul. 2012
I would recommend first writing a MATLAB function to call into your Java function and get the selected file name. See Using Java Libraries from MATLAB for documentation regarding this. Once you have tested this, call this from your model's PostLoadFcn or InitFcn callbacks, so that the MATLAB function is called everytime the model is loaded or run. In your MATLAB function, you can also use set_param to set the S-function name to that returned from the Java function. Note that you may need to add the selected folder to the MATLAB path if it isn't already there.

Kategorien

Mehr zu Call Java from MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by