clear all;
clc;
finp = fopen('CADM.out');
tinp = textscan(finp, '%s %f %f %f %f %f %f %f', 'HeaderLines', 1);
fclose(finp);
%ARITMETICKÝ PRŮMĚR
date = datetime(tinp{:,1});
x    = tinp{:,2};
y    = tinp{:,3};
z    = tinp{:,4};
sx   = tinp{:,5};
sy   = tinp{:,6};
sz   = tinp{:,7};
m0   = tinp{:,8};
avex=mean(x,'all')
avey=mean(y,'all')
avez=mean(z,'all')
avesx=mean(sx,'all')
avesy=mean(sy,'all')
avesz=mean(sz,'all')
avem0=mean(m0,'all')


out = fopen('CADMFINAL.out','w');
fprintf(out,' X(ECEF)       Y(ECEF)          Z(ECEF)     sX      sY      sZ      m0 \r\n');
    fprintf(out,  '%0.4f   %0.4f   %0.4f    %0.4f   %0.4f   %0.4f   %0.4f',avex,avey,avez,avesx, avesy, avesz, avem0 );
    fclose (out);