
%% peak values of the accelerometers (m/s^2)
a1 = 86.55;
a2 = -244.06;
a3 = 788.51;
a4 = 1299.8;
a5 = -876.19;
a6 = -84.90;

%% position vectors (m) of the accelerometers (with respect to the center of mass)
r1= [-.02302764 .05369052 .08863076];
r2= [.06011164 .07401052 .0505206];
r3= [.09201404 .04697984 .0469138];
r4= [.10111232 -.02482596 .4757928];
r5= [.07916672 -.05525516 .05690108];
r6= [-.0221488 -.05701284 .08810244];

%% orientation vectors (m) of the accelerometers (tangent to the surface)
e1 =[0    0.9146   -0.4044];
e2 =[0    0.5252   -0.8510];
e3 =[0.3650         0   -0.9310];
e4 =[0.3450         0   -0.9386];
e5 =[0.4939    0.8695         0];
e6 =[-0.9357    0.3527         0];

%%%%%%%SOLUTION

%% set up matrix equation AX=B
B = [a1; a2; a3; a4; a5; a6];
A1 = [e1(1) e1(2) e1(3) -r1(3)*e1(2)+r1(2)*e1(3) r1(3)*e1(1)-r1(1)*e1(3) -r1(2)*e1(1)+r1(1)*e1(2)];
A2 = [e2(1) e2(2) e2(3) -r2(3)*e2(2)+r2(2)*e2(3) r2(3)*e2(1)-r2(1)*e2(3) -r2(2)*e2(1)+r2(1)*e2(2)];
A3 = [e3(1) e3(2) e3(3) -r3(3)*e3(2)+r3(2)*e3(3) r3(3)*e3(1)-r3(1)*e3(3) -r3(2)*e3(1)+r3(1)*e3(2)];
A4 = [e4(1) e4(2) e4(3) -r4(3)*e4(2)+r4(2)*e4(3) r4(3)*e4(1)-r4(1)*e4(3) -r4(2)*e4(1)+r4(1)*e4(2)];
A5 = [e5(1) e5(2) e5(3) -r5(3)*e5(2)+r5(2)*e5(3) r5(3)*e5(1)-r5(1)*e5(3) -r5(2)*e5(1)+r5(1)*e5(2)];
A6 = [e6(1) e6(2) e6(3) -r6(3)*e6(2)+r6(2)*e6(3) r6(3)*e6(1)-r6(1)*e6(3) -r6(2)*e6(1)+r6(1)*e6(2)];
A = [A1; A2; A3; A4; A5; A6];

%% solve for X
X = linsolve(A,B);

%% find the magnitude of the net acceleration
aCM = sqrt(X(1)^2+X(2)^2+X(3)^2)