%
%   caligrate the accelerometer number 26
%
g=9.81;
load cal26.txyz
t=cal26(:,1);
N=length(t);
i=1:N;
x=cal26(:,2);
y=cal26(:,3);
z=cal26(:,4);
cal=cal26(:,5);
%
%   plot each chanel
%
subplot(4,1,1);plot(i,x);
axis([0,N,-12.,12.])
%axis([0,N,1600,2600])
%ylabel('counts')
ylabel('acceleration m/s**2')
title('CH1')
subplot(4,1,2);plot(i,y);
axis([0,N,-12.,12.])
%ylabel('counts')
ylabel('acceleration m/s**2')
title('CH2')
subplot(4,1,3);plot(i,z);
axis([0,N,-12.,12.])
%ylabel('counts')
ylabel('acceleration m/s**2')
title('CH3')
subplot(4,1,4);plot(i,cal);
axis([0,N,0.,2.])
ylabel('|g|/g0')
title('magnitude')
xlabel('measurement number')
%
% clip out the data and analyze
%
% CH1
%
ch1p=mean(x(0050:0550));
sch1p=std(x(0050:0550));
ch1n=mean(x(0750:1400));
sch1n=std(x(0750:1400));
ch1p;
sch1p;
ch1n;
sch1n;
%
% CH2
%
ch2p=mean(y(1550:2100));
sch2p=std(y(1550:2100));
ch2n=mean(y(2300:2800));
sch2n=std(y(2300:2800));
ch2p;
sch2p;
ch2n;
sch2n;
%
% CH3
%
ch3n=mean(z(2950:3430));
sch3n=std(z(2950:3430));
ch3p=mean(z(3700:4400));
sch3p=std(z(3700:4400));
ch3p;
sch3p;
ch3n;
sch3n;
%
%   compute the scale factor and offset for each chanel
%
sx=2.*g/(ch1n-ch1p)
ox=(ch1p+ch1n)/2
sy=2.*g/(ch2n-ch2p)
oy=(ch2p+ch2n)/2
sz=2.*g/(ch3n-ch3p)
oz=(ch3p+ch3n)/2
