-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathloadPltFileFun.m
37 lines (34 loc) · 933 Bytes
/
loadPltFileFun.m
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
35
36
37
function [plotFlag,corArray]=loadPltFileFun(fileName)
%% load the plt file into arrays
% Copyright: Mohammad SAFEEA, 7th-Nov-2018
%% Areguments:
% fileName: is the name of the file, it shall be with PLT format
%% Return values:
% plotFlag: 1 for up, 0 for down.
% corArray: is an array of the coordinates, in meters.
fid = fopen(fileName);
x=fread(fid);
n=max(size(x));
corArray=[];
plotFlag=[];
line='';
oldCoord=[0;
0];
for i=1:n
daChar=char(x(i));
line=[line,daChar];
if daChar==';'
[isValid,upDown,coord]=processLine(line,oldCoord);
line='';
if isValid==1
oldCoord=coord;
corArray=[corArray,coord];
plotFlag=[plotFlag,upDown];
end
end
end
% plot(corArray(1,:),corArray(2,:))
corArray=corArray*25.4/1016; % convert coordinates to mm
corArray=corArray/1000; % convert coordinates to meter
fclose(fid)
end