restart(scenario) restarts the simulation of the
driving scenario, scenario, from the beginning. The function sets the
SimulationTime property of the driving scenario to
0.
ans =
Road with properties:
Name: ""
RoadID: 1
RoadCenters: [2×3 double]
RoadWidth: 6
BankAngle: [2×1 double]
Heading: [2×1 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
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.