%% Import data from text file.
% Script for importing data from the following text file:
%
%    C:\Users\Joseph\Documents\MATLAB\Balloon
%    2015_11_14\helios_to_matlab1.txt
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.

% Auto-generated by MATLAB on 2015/11/16 19:30:40

%% Initialize variables.
filename = 'C:\Users\Joseph\Documents\MATLAB\Balloon 2015_11_14\helios_to_matlab1.txt';
delimiter = ',';
startRow = 5573;

%% Format string for each line of text:
%   column1: double (%f)
%	column2: double (%f)
%   column3: double (%f)
%	column4: double (%f)
%   column5: double (%f)
%	column6: double (%f)
%   column7: double (%f)
%	column8: double (%f)
%   column9: double (%f)
%	column10: text (%s)
%   column11: text (%s)
%	column12: double (%f)
%   column13: double (%f)
%	column14: double (%f)
%   column15: double (%f)
%	column16: double (%f)
%   column17: double (%f)
%	column18: double (%f)
%   column19: double (%f)
%	column20: double (%f)
%   column21: double (%f)
%	column22: double (%f)
%   column23: double (%f)
%	column24: double (%f)
%   column25: double (%f)
%	column26: double (%f)
%   column27: double (%f)
%	column28: double (%f)
%   column29: double (%f)
%	column30: double (%f)
%   column31: double (%f)
%	column32: double (%f)
%   column33: double (%f)
%	column34: double (%f)
%   column35: double (%f)
%	column36: double (%f)
%   column37: double (%f)
%	column38: double (%f)
%   column39: double (%f)
%	column40: double (%f)
%   column41: double (%f)
%	column42: double (%f)
%   column43: double (%f)
%	column44: double (%f)
%   column45: text (%s)
%	column46: double (%f)
%   column47: text (%s)
%	column48: double (%f)
%   column49: double (%f)
%	column50: double (%f)
%   column51: double (%f)
%	column52: double (%f)
%   column53: double (%f)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%f%f%f%f%f%f%f%f%f%s%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%s%f%s%f%f%f%f%f%f%[^\n\r]';

%% Open the text file.
fileID = fopen(filename,'r');

%% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines' ,startRow-1, 'ReturnOnError', false);

%% Close the text file.
fclose(fileID);

%% Post processing for unimportable data.
% No unimportable data rules were applied during the import, so no post
% processing code is included. To generate code which works for
% unimportable data, select unimportable cells in a file and regenerate the
% script.

%% Allocate imported array to column variable names
clock = dataArray{:, 1};
presIn = dataArray{:, 2};
presOut = dataArray{:, 3};
tempIn = dataArray{:, 4};
tempOut = dataArray{:, 5};
rawD1In = dataArray{:, 6};
rawD2In = dataArray{:, 7};
rawD1Out = dataArray{:, 8};
rawD2Out = dataArray{:, 9};
valveOpen = dataArray{:, 10};
valveReclosed = dataArray{:, 11};
tempBNO = dataArray{:, 12};
qW = dataArray{:, 13};
qX = dataArray{:, 14};
qY = dataArray{:, 15};
qZ = dataArray{:, 16};
eulerX = dataArray{:, 17};
eulerY = dataArray{:, 18};
eulerZ = dataArray{:, 19};
orientX = dataArray{:, 20};
orientY = dataArray{:, 21};
orientZ = dataArray{:, 22};
accelX = dataArray{:, 23};
accelY = dataArray{:, 24};
accelZ = dataArray{:, 25};
gyroX = dataArray{:, 26};
gyroY = dataArray{:, 27};
gyroZ = dataArray{:, 28};
linAccelX = dataArray{:, 29};
linAccelY = dataArray{:, 30};
linAccelZ = dataArray{:, 31};
gravityX = dataArray{:, 32};
gravityY = dataArray{:, 33};
gravityZ = dataArray{:, 34};
calGyro = dataArray{:, 35};
calAccel = dataArray{:, 36};
calMagnet = dataArray{:, 37};
hours = dataArray{:, 38};
minutes = dataArray{:, 39};
seconds = dataArray{:, 40};
milliseconds = dataArray{:, 41};
fix = dataArray{:, 42};
fixQ = dataArray{:, 43};
latitude = dataArray{:, 44};
latDirection = dataArray{:, 45};
longitude = dataArray{:, 46};
longDirection = dataArray{:, 47};
latDegree = dataArray{:, 48};
longDegree = dataArray{:, 49};
speed = dataArray{:, 50};
angle = dataArray{:, 51};
altitude = dataArray{:, 52};
delay = dataArray{:, 53};

%% Clear temporary variables
clearvars filename delimiter startRow formatSpec fileID dataArray ans;