function lorry=Lorry_plotfigureview(3)grid onaxis ('equal');% lorry
vertices_lorry = [0 1 0.5 ; 4 1 0.5; 6.5 1 0.5; 6.5 1 1.2; 6 1 1.3;... 5 1 1.8; 4 1 1.8; 4 1 2; 0 1 2; ... % postive y of lorry 0 -1 0.5; 4 -1 0.5; 6.5 -1 0.5; 6.5 -1 1.2; 6 -1 1.3;... 5 -1 1.8; 4 -1 1.8; 4 -1 2; 0 -1 2]; % negative y of lorry
faces_lorry_cargo = [10 1 9 18; 1 2 8 9; 8 9 18 17; 10 11 17 18;... 7 8 17 16; 1 2 11 10];faces_lorry_driver = [7 6 15 16 16 16; 5 6 15 14 14 14; 5 4 13 14 14 14;... 3 4 13 12 12 12; 2 3 4 5 6 7; 11 12 13 14 15 16; 2 3 12 11 11 11];lorry(1)=patch('Faces',faces_lorry_cargo,'Vertices',vertices_lorry,'FaceColor',... '#86DA7D','EdgeColor','k');lorry(2)=patch('Faces',faces_lorry_driver,'Vertices',vertices_lorry,'FaceColor',... '#868686','EdgeColor','k');% wheels
t = linspace(pi,2*pi,8)';[a,b] = pol2cart(t,0.5); % create data for circle
v0 = a*0;X = [v0 a a v0];Z = [v0 b b v0];Y = [v0-1 v0-1 v0+1 v0+1]*0.15; hold onlorry(3)=surf(X+1,Y+.85,Z+.5,'facecolor','#555555'); % draw wheel rear left
lorry(4)=surf(X+1,Y-.85,Z+.5,'facecolor','#555555'); % draw wheel rear right
lorry(5)=surf(X+4.95,Y+.85,Z+.5,'facecolor','#555555'); % draw wheel front left
lorry(6)=surf(X+4.95,Y-.85,Z+.5,'facecolor','#555555'); % draw wheel front right
hold off% truss
vertices_truss = [0 2 0; 4 2 0; 8 2 0; 12 2 0; 16 2 0; 20 2 0; 24 2 0;... 20 2 4; 16 2 4; 12 2 4; 8 2 4; 4 2 4;... % pink truss positive y 0 -2 0; 4 -2 0; 8 -2 0; 12 -2 0; 16 -2 0; 20 -2 0; 24 -2 0;... 20 -2 4; 16 -2 4; 12 -2 4; 8 -2 4; 4 -2 4]; % blue truss negative y
faces_truss = [1 2;2 3;3 4;4 5;5 6;6 7;7 8;8 9;9 10;10 11;11 12;12 1;12 2;12 3;... 11 3;11 4;10 4;9 4;9 5;8 5;8 6;... %pink side 13 14;14 15;15 16;16 17;17 18;18 19;19 20;20 21;21 22;22 23;23 24;... 24 13;24 14;24 15;23 15;23 16;22 16;21 16;21 17;20 17;20 18;... %blue side 1 13;2 14;3 15;4 16;5 17;6 18;7 19;8 20;9 21;10 22;11 23;12 24]; %transverse
patch('Faces',faces_truss,'Vertices',vertices_truss,'FaceAlpha',0);end
This file plots a truck and a truss. How can I make this into an animation so the truck(lorry) moves across the bridge in increments of 0.01?
Best Answer