restart
Restart driving scenario simulation from beginning
Syntax
Description
Examples
Restart Driving Scenario Simulation
Create a driving scenario in which a vehicle travels down a straight, 25-meter road at 20 meters per second. Plot the scenario.
scenario = drivingScenario('SampleTime',0.1);
roadcenters= [0 0 0; 25 0 0];
road(scenario,roadcenters)
ans = Road with properties: Name: "" RoadID: 1 RoadCenters: [2x3 double] RoadWidth: 6 BankAngle: [2x1 double] Heading: [2x1 double]
v = vehicle(scenario,'ClassID',1); waypoints = [5 0 0; 20 0 0]; speed = 20; % m/s smoothTrajectory(v,waypoints,speed) plot(scenario)
Run the simulation and display the location of the vehicle at each time step.
while advance(scenario) fprintf('Vehicle location: %0.2f meters at t = %0.0f ms\n', ... v.Position(1), ... scenario.SimulationTime * 1000) end
Vehicle location: 7.00 meters at t = 100 ms Vehicle location: 9.00 meters at t = 200 ms Vehicle location: 11.00 meters at t = 300 ms Vehicle location: 13.00 meters at t = 400 ms Vehicle location: 15.00 meters at t = 500 ms Vehicle location: 17.00 meters at t = 600 ms Vehicle location: 19.00 meters at t = 700 ms
Restart the simulation. Increase the sample time and rerun the simulation.
restart(scenario); scenario.SampleTime = 0.2; while advance(scenario) fprintf('Vehicle location: %0.2f meters at t = %0.0f ms\n', ... v.Position(1), ... scenario.SimulationTime * 1000) end
Vehicle location: 9.00 meters at t = 200 ms Vehicle location: 13.00 meters at t = 400 ms Vehicle location: 17.00 meters at t = 600 ms
Input Arguments
scenario
— Driving scenario
drivingScenario
object
Driving scenario, specified as a drivingScenario
object.
Version History
Introduced in R2017a
See Also
Objects
Functions
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)