forked from shreyshahi/PulseClassification
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathparseAT2.m
More file actions
34 lines (33 loc) · 1.04 KB
/
parseAT2.m
File metadata and controls
34 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Parser for NGA West2 AT2 files
% ---------------------------------
% Input : Full path of the file to be parsed
%
% Outputs:
% -Acceleration time history (Acc)
% -Time step used for recording (record_dt)
% -Number of recorded points (NPTS)
% -error code to indicate if the file was not present (errCode)
% --errCode = 0 if successful, -1 if File not found
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Acc,record_dt,NPTS,errCode] = parseAT2(filename)
file_in = fopen(filename, 'r');
if(file_in == -1)
Acc = -1;
record_dt = -1;
errCode = -1;
NPTS = -1;
else
for j=1:3
ans = fgetl(file_in);
end
[a1 ans] = fscanf(file_in, '%5c', 1);
[NPTS ans] = fscanf(file_in, '%s', 1);
NPTS = str2double(NPTS(1:end-1));
[a3 ans] = fscanf(file_in, '%s', 1);
[record_dt ans] = fscanf(file_in, '%f', 1);
ans = fgetl(file_in);
[Acc, np] = fscanf(file_in, '%f');
fclose(file_in);
errCode = 0;
end