Is it possible to call JAVA code from within Simulink?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to use Simulink to call, run, or use a JAVA program. I wonder if this can be done using an S-function.
Réponse acceptée
MathWorks Support Team
le 24 Fév 2012
There is no direct functionality to call JAVA code from Simulink. One possible workaround is to use an S-function block. The S-function blocks are written in MATLAB, C, C++ or Ada code.
In the attached example, we show how a Level-2 MATLAB S-function block with appropriate block parameters and callbacks setup ; is able to call java code.
A simple Java call example is provided in the attached files wherein a Java String is created and the raw bytes are extracted from it and displayed. The Java Code has been placed in the 'output' callback of the S-Function, so it executes every time an output needs to be produced. Please look into the MATLAB Code of the S-Function block by right-clicking the S-Function block and choosing 'Look Under Mask'. This example has been created by modifying the MATLAB Times Two S-Function example that ships with MATLAB.
Please note that using Java calls with S-function may lead users to believe that it may be possible to do the same in Embedded MATLAB function block. However, this is not advisable because if you need to import any of the Java libraries using the 'IMPORT' function, this can not be done as Embedded MATLAB Fcn Block does not support the IMPORT command.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Block and Blockset Authoring dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!