Clear Filters
Clear Filters

Embed SimMechanics Visualization in MATLAB GUI

13 views (last 30 days)
I have a MATLAB GUI that will run a SimMechanics model and would like to embed the visualization window in the GUI. Is there any way to do this? I have seen people suggest saving the visualization as an avi file, which wouldn't allow for interaction (which would be ideal), but I'll take what I can get. If that is the only way, is there any way to automatically save a visualization as an avi file? I know there is a setting in the Simulation menu for 1st Gen SimMechanics, but I am running 2nd Gen and there doesn't seem to be any such setting. If there isn't, is there any way to save the visualization from the command window? And from there, how would I be able to run the avi animation on the axes?

Answers (1)

Steve Miller
Steve Miller on 8 Mar 2018
I do not believe there is a way to embed the Mechanics Explorer in a MATLAB GUI. You can, however, dock the Mechanics Explorer in the MATLAB desktop, which will give you the same effect.
You can generate videos from the Mechanics Explorer from the command line using the command smwritevideo
To control the viewpoint of your video, you can define cameras within the Mechanics Explorer. The location and orientation of the camera can change during the animation of the simulation results, and those results can be exported to a video.
See Camera Manager in the documentation.
Below is an example of an animation exported from the Simscape Multibody Mechanics Explorer with a dynamic camera. The camera can also be configured to track the box, always keeping it in the center of the frame. This example is available on the File Exchange: Robot Arm with Conveyor Belts.
--Steve

Categories

Find more on Simulation and Analysis in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!