Question
I created a model that drives a virtual world. When I generate and build code from this model, I am unable to control the virtual world with the generated executable.
Expert Answer
John Michell
PhD Expert
Answered Sep 12, 2026
he generated code alone cannot be used to control the virtual world. You must interface to the generated code using External mode. For example, open the demo vrmaglev and follow these steps.
1. Select Tools->Real-Time Workshop->Options
2. Click on the Interface node.
3. In the Data Exchange section, select External Mode from the pull down menu.
4. Push the OK button.
5. Build the model (CTRL-B).
6. From the model menu, select Simulation->External Mode
7. Type the following at the MATLAB command window
!vrmaglev -w
to start the generated executable. Note the -w option will put the executable into a wait state until the host (Simulink) connects to the code.
8. Open the VR window by double clicking on the VR Sink block.
9. Next, you will connect to the running code by selecting Simulation->Connect to Target
10. Once the target is connected, the Simulink "Play" button should be active. Pushing the "Play" button will cause the generated code to drive the VR animation.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related vr Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →