How can I use Driving Scenario Interactively?

Angelo Coppola · May 10, 2023 · 2.3K views
Question
 I would like to update vehicles state information (position, speed) step by step, and not give them as predefine values. For example, I would like to take this information from a traffic simulator, like SUMO.
Expert Answer
Profile picture of Prashant Kumar
Prashant Kumar PhD Expert
Answered Aug 25, 2026

You can set the position and orientation properties directly. Here's an example setting the X position to drive up a straight road.

 

d = drivingScenario;
road(d, [0 0; 25 0])
v = actor(d, 'Position', [1 0 0]);
plot(d);
for index = 1:0.1:20
    v.Position = [index 0 0];
    advance(d);
    pause(0.01)
end

And Here's an example settings the Yaw with the car appearing to be spinning out

for index = 1:0.1:20
    v.Position = [index 0 0];
    v.Yaw = index*5;
    advance(d);
    pause(0.01)
end

 

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

Get a Free Consultation or a Sample Assignment Review!