clc clear all %enter number f points to simulate for num=10000; bin=100; %enter range of locations of the wheels Xwheel = [0 0 10 10; 1 1 9 9] Ywheel = [0 10 0 10; 1 9 1 9]; %enter range of masses of components m = [250 350 430; 275 330 420]; %enter ranges of locations of components Xlocation = [4 5 6; 5 4 5]; Ylocation = [4 5 6; 5 4 5]; Zlocation = [4 5 6; 5 4 5]; vmax=2; %assumming the coordinates are random variables uniformly distributed %across the range [r c]=size(Xwheel); for i = 1:1:c Xmwheel(:,i)=rand(num,1)*(Xwheel(1,i)-Xwheel(2,i))+Xwheel(2,i); Ymwheel(:,i)=rand(num,1)*(Ywheel(1,i)-Ywheel(2,i))+Ywheel(2,i); end; [r c]=size(m); for i = 1:1:c Xmlocation(:,i)=rand(num,1)*(Xlocation(1,i)-Xlocation(2,i))+Xlocation(2,i); Ymlocation(:,i)=rand(num,1)*(Ylocation(1,i)-Ylocation(2,i))+Ylocation(2,i); Zmlocation(:,i)=rand(num,1)*(Zlocation(1,i)-Zlocation(2,i))+Zlocation(2,i); mass(:,i)=rand(num,1)*(m(1,i)-m(2,i))+m(2,i); end; for i = 1:1:num A=CenterofCG(vmax, Xmwheel(i,:), Ymwheel(i,:), Xmlocation(i,:), Ymlocation(i,:), Zmlocation(i,:), mass(i,:)); r(i)=A(1); alin(i)=A(2); incline(i)=A(3); end; figure; subplot(3,1,1) hist(r,bin) xlabel('maximum turning radius in m'); subplot(3,1,2) hist(alin,bin) xlabel('maximum linear acceleration'); subplot(3,1,3) hist(incline,bin) xlabel('maximum incline');