forked from arrowmaster/MapSatAltitude
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparsePlanetInfo.m
More file actions
30 lines (27 loc) · 815 Bytes
/
parsePlanetInfo.m
File metadata and controls
30 lines (27 loc) · 815 Bytes
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
function Planets = parsePlanetInfo(filename)
if nargin < 1
fid = fopen('planetInfos.txt');
else
fid = fopen(filename);
end
headerline = fgetl(fid);
C = textscan(fid, '%s %f %f %f %f %f','Delimiter','\b\r\n\t','MultipleDelimsAsOne',1,'CommentStyle','%');
h = strread(headerline,'%s'); % ^^^ this lets us put comments in the files
% ^^ this combines all tabs into one delimiter,
% so the data file can look nice
% ^ this removes ' ' from being a valid delimiter
% so that strings with spaces can be sucked up by %s
fclose(fid);
for i = 1:length(C{1})
for j = 1:length(h)
field = h{j};
if iscell(C{j})
fieldVal = C{j}{i};
else
fieldVal = C{j}(i);
end
P.(field)=fieldVal;
end
Planets(i)=P;
end
end