Select Git revision
readACC.m 790 B
function ACC1B = readACC(file)
% Input: ascii file containing GRACE ACC1B data
% Output: matrix containing ACC1B data
%
% cf. GRACE Level 1B Data Product User Handbook
%
% Example: ACC1B = readACC('ACC1B_2002-12-02_A_02.asc')
% Counts header lines and removes them.
header=0;
fid = fopen(file);
while 1
line = fgetl(fid);
header = header+1;
if (~isempty(strfind(line,'END OF HEADER')))
break
end
end
% Reads the desired values from ACC1B data.
[gps_time, lin_acc_x, lin_acc_y, lin_acc_z, ang_acc_x, ang_acc_y, ang_acc_z] = textread(file,'%f %*s %f %f %f %f %f %f %*f %*f %*f %*f','headerlines',header);
% Produces the matrix containing the desired values.
ACC1B = [gps_time, lin_acc_x, lin_acc_y, lin_acc_z, ang_acc_x, ang_acc_y, ang_acc_z];
end