Chase plot changes figure size internally
Afficher commentaires plus anciens
I am trying to run a driving Scenario in a chase Plot and save the animation in a figure as:
scenario = drivingScenario;
ls = lanespec(2,'Width',5);
roadCenters = [-20 0; 5 0];
road(scenario,roadCenters,'Name','Road 1','Lanes',ls);
roadCenters = [10 5; 10 30];
road(scenario,roadCenters,'Name','Road 2','Lanes',ls);
roadCenters = [10 -5; 10 -30];
road(scenario,roadCenters,'Name','Road 3','Lanes',ls);
roadCenters = [15 0; 40 0];
road(scenario,roadCenters,'Name','Road 2','Lanes',ls);
car1 = vehicle(scenario, 'ClassID', 1, 'Position', [-20, -2.5, 0], 'Length', ...
3, 'Width', 2, 'Height', 1.5);
waypoints = [-20, -2.5; 40, -2.5];
speed = [12 12];
yaw = [0 0];
smoothTrajectory(car1, waypoints, speed, 'Yaw', yaw, 'Jerk', 2);
vidObj2 = VideoWriter('SCP_Chase_Plot','MPEG-4');
open(vidObj2);
fig2 = figure('Name', 'Chase Plot', 'Units', 'pixels', 'Position', [100, 100, 640, 480]);
ax2 = axes('Parent', fig2);
chasePlot(car1,'Centerline','on', 'Parent', ax2);
set(fig2, 'Units', 'pixels', 'Position', [100, 100, 640, 480]);
while advance(scenario)
set(fig2, 'Units', 'pixels', 'Position', [100, 100, 640, 480]);
frame2 = getframe(ax2);
writeVideo(vidObj2, frame2);
pause(0.01)
end
However, when I run the code, it gives me the error:
Error using VideoWriter/writeVideo (line 368)
Frame must be 640 by 480
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Weather and Atmospheric Science dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!