function A=CenterofCG(vmax, Xwheel, Ywheel, Xlocation, Ylocation, Zlocation, m) g=9.8; %enter locations of the wheels %Xwheel = [0 0 10 10]; %Ywheel = [0 10 0 10]; %enter masses of components %m = [250 350 430]; %enter location of components %Xlocation = [4 5 6]; %Ylocation = [4 5 6]; %Zlocation = [4 5 6]; Xcenter=0; Ycenter=0; Zcenter=0; mass=0; for i=1:1:length(m); Xcenter=Xcenter+Xlocation(i); Ycenter=Ycenter+Ylocation(i); Zcenter=Zcenter+Zlocation(i); mass=mass+m(i); end; Xcenter=Xcenter/length(m) Ycenter=Ycenter/length(m) Zcenter=Zcenter/length(m) mass % computing shortest half wheelbase Xbase=min(abs(Xwheel-Xcenter)) Ybase=min(abs(Xwheel-Xcenter)) % Computing maximum turning acceleration aturn=Xbase*g/Zcenter % Computing maximum turning radius r=vmax^2/aturn % Computing maximum linear acceleration alin=Ybase*g/Zcenter % Computing maximum incline incline=atan(Ybase/Zcenter)*180/pi A=[r,alin,incline];