Hello,
I have cleaned up a little bit of your code. You can create a function that will plot a cornerlight on the position to make it even more compact. The issue was with rectangle function and hold on, rectangle plots each time a new one when you call it. Getting a handle for rectangle and changing its Position property as shown below can solve your issue.
axis equal
hold on;
format long g; format compact;
%%-lower right corner light------------------------
LRCL = rectangle('Position', [0+64 0+30 2 4],'Curvature', 0.2,'FaceColor', 'k');
darkGray = [0.2, 0.2, 0.2];
green = [0, 132, 80] / 255;
yellow = [239, 183, 0] / 255;
red = [184, 29, 19] / 255;
pos = [0.5+64 2.75+30 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [0.5+64 1.5+30 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [0.5+64 0.25+30 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', red)
%%-upper left corner ---------------------------------
ULCL = rectangle('Position', [0+35 0+64 2 4],'Curvature', 0.2,'FaceColor', 'k')
darkGray = [0.2, 0.2, 0.2];
green = [0, 132, 80] / 255;
yellow = [239, 183, 0] / 255;
red = [184, 29, 19] / 255;
pos = [0.5+35 2.75+64 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', red)
pos = [0.5+35 1.5+64 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [0.5+35 0.25+64 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
%%-lower left corner light-------------------------------
rectangle('Position', [0+30 0+35 4 2],'Curvature', 0.2,'FaceColor', 'k')
darkGray = [0.2, 0.2, 0.2];
green = [0, 132, 80] / 255;
yellow = [239, 183, 0] / 255;
red = [184, 29, 19] / 255;
pos = [2.75+30 0.5+35 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', green)
pos = [1.5+30 0.5+35 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [0.25+30 0.5+35 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
%%-upper right corner light--------------------------
rectangle('Position', [0+65 0+65 4 2],'Curvature', 0.2,'FaceColor', 'k')
darkGray = [0.2, 0.2, 0.2];
green = [0, 132, 80] / 255;
yellow = [239, 183, 0] / 255;
red = [184, 29, 19] / 255;
pos = [2.75+65 0.5+65 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [1.5+65 0.5+65 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', darkGray)
pos = [0.25+65 0.5+65 1 1];
rectangle('Position', pos, 'Curvature',[1 1], 'FaceColor', green)
k=0;
% defining red car
redCar = rectangle('FaceColor','red','Edgecolor','red','Position',[55 k 3 7]);
while k<=90
redCar.Position = [55 k 3 7];
k=k+1;
pause(0.1)
end
% defining magenta car
k=65;
magentaCar = rectangle('FaceColor','magenta','EdgeColor','magenta','Position',[43 k 4 8])
while k<=65 && k>=0
k=k-1;
magentaCar.Position = [43 k 4 8];
pause(0.1)
end
pause(5)