This repository has been archived by the owner on Feb 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadFileData.m
59 lines (45 loc) · 2.1 KB
/
readFileData.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [ comm_time light_time] = readFileData(comm_file, light_file)
%readFileData Read in data used by the simulation program
% This will read in the following data from their respective files:
% - Light exposure times
% - Communication windows
% - Power draws for spacecraft systems
%%
% Read in and convert the lighting data into seconds since 1/1/14 12:00 AM
% Open the lighting data
lighting_data = importdata(light_file,',');
% Create the array for the converted lighting values
light_time = zeros(1,1);
% Compute the seconds of the first point
first_date_sec = compute_seconds('1/1/14 12:00 AM', 'mm/dd/yy HH:MM AM');
% Convert the first column of the array into seconds since 1/1/14 12:00 AM
for i=1:1:length(lighting_data.textdata(:,1))-1
% Store the seconds since the first value in the array
light_time(i,1) = compute_seconds(lighting_data.textdata(i+1,1), 'mm/dd/yy HH:MM AM') - first_date_sec;
end
% Convert the second column of the array into seconds since 1/1/14 12:00 AM
for i=1:1:length(light_time)
% Store the end of the light time in the second column of the array
light_time(i,2) = light_time(i,1) + lighting_data.data(i);
end
%%
% Read in and convert the communication window data into seconds since 1/1/14 12:00 AM
%
% Open the communications data
comm_data = importdata(comm_file,',');
% Create the array for the converted communications values
comm_time = zeros(1,1);
% Compute the seconds of the first point
first_date_sec = compute_seconds('1/1/2014 0:00', 'mm/dd/yyyy HH:MM');
% Convert the first column of the array into seconds since 1/1/2014 12:00
for i=1:1:length(comm_data.textdata(:,1))-1
% Store the seconds since the first value in the array
comm_time(i,1) = compute_seconds(comm_data.textdata(i+1,1), 'mm/dd/yyyy HH:MM') - first_date_sec;
end
% Convert the second column of the array into seconds since 1/1/2014 12:00
for i=1:1:length(comm_time)
% Store the end of the light time in the second column of the array
comm_time(i,2) = comm_time(i,1) + comm_data.data(i);
end
% Function end
end