How can I create MATLAB animations using data from Simulink 7.1 (R2008a)?

4 views (last 30 days)
I would like to display MATLAB animations using MATLAB script in the Simulink environment.
The input data should be coming from a Simulink block and an external hardware.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 May 2022
Edited: MathWorks Support Team on 18 May 2022
There are several options you can use depending on the specific needs and constraints of your application.
To use a MATLAB script to create MATLAB animations in a Simulink environment, you can:
1. Import the script into an Embedded MATLAB Function block and make eml.extrinsic calls to use dispatch MATLAB functions to the MATLAB engine. Note the model will have to be simulated in Normal mode.
2. Use a Level 2 S-Function block and interface the MATLAB script with the S-Function API. Note the model will have to be simulated in Normal mode.
3. Use the MATLAB Compiler to compile the MATLAB script into an executable and have it interface with Simulink.
4. Other options include code generation, but that will no longer use the MATLAB script.
If you want to use real-time or near real-time animations, it introduces another layer of complexity.
The best option then would be to use Simulink 3D and Real Time Windows Target. You will then need to rewrite your MATLAB script in VRML and interface it with a Simulink-3D block. The advantage here is that Simulink-3D is compatible to Real Time Windows Target and it is designed to interface with Simulink.
Here are some demos to Simulink 3D:
Also, you could write your own C-file that does the graphical display. The C-file can be integrated with the code generation of S-Functions.

More Answers (1)

MathWorks Support Team
MathWorks Support Team on 18 Aug 2009
There are several options you can use depending on the specific needs and constraints of your application.
To use a MATLAB script to create MATLAB animations in a Simulink environment, you can:
1. Import the script into an Embedded MATLAB Function block and make eml.extrinsic calls to use dispatch MATLAB functions to the MATLAB engine. Note the model will have to be simulated in Normal mode.
2. Use a Level 2 S-Function block and interface the MATLAB script with the S-Function API. Note the model will have to be simulated in Normal mode.
3. Use the MATLAB Compiler to compile the MATLAB script into an executable and have it interface with Simulink.
4. Other options include code generation, but that will no longer use the MATLAB script.
If you want to use real-time or near real-time animations, it introduces another layer of complexity.
The best option then would be to use Simulink 3D and Real Time Windows Target. You will then need to rewrite your MATLAB script in VRML and interface it with a Simulink-3D block. The advantage here is that Simulink-3D is compatible to Real Time Windows Target and it is designed to interface with Simulink.
Here are some demos to Simulink 3D:
Also, you could write your own C-file that does the graphical display. The C-file can be integrated with the code generation of S-Functions.

Categories

Community Treasure Hunt

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

Start Hunting!