function L1b = L1b_importfile(filename, startRow, endRow)
%IMPORTFILE Import numeric data from a text file as column vectors.
%   [T_UNIX,T_SCLK,T_TID,TID,UMKID,ORBIT,FMODE,MULTIPLIER,FILAMENT,TEMP_S,MASS,COUNTS,CPS_RAW,CPS_RAW_BKGD,CPS_DT,CPS_DT_BKGD,BKGD,ALT_IAU,VSC_IAU,RAM1_POS,RAM2_VEL,RA_APP,DEC_APP,X,Y,Z,VX,VY,VZ,LAT,LONG]
%   = IMPORTFILE(FILENAME) Reads data from text file FILENAME for the
%   default selection.
%
%   [T_UNIX,T_SCLK,T_TID,TID,UMKID,ORBIT,FMODE,MULTIPLIER,FILAMENT,TEMP_S,MASS,COUNTS,CPS_RAW,CPS_RAW_BKGD,CPS_DT,CPS_DT_BKGD,BKGD,ALT_IAU,VSC_IAU,RAM1_POS,RAM2_VEL,RA_APP,DEC_APP,X,Y,Z,VX,VY,VZ,LAT,LONG]
%   = IMPORTFILE(FILENAME, STARTROW, ENDROW) Reads data from rows STARTROW
%   through ENDROW of text file FILENAME.
%
% Example:
%   [t_unix,t_sclk,t_tid,tid,umkid,orbit,fmode,multiplier,filament,temp_s,mass,counts,cps_raw,cps_raw_bkgd,cps_dt,cps_dt_bkgd,bkgd,alt_iau,vsc_iau,ram1_pos,ram2_vel,ra_app,dec_app,x,y,z,vx,vy,vz,lat,long]
%   = importfile('mvn_ngi_L1b_CS-ION_14015_20141018T152646_v01_r01.csv',2,
%   35412);
%
%    See also TEXTSCAN.

% Auto-generated by MATLAB on 2014/11/18 11:47:21

%% Initialize variables.
delimiter = ',';
if nargin<=2
    startRow = 2;
    endRow = inf;
end

%% Format string for each line of text:
%   column1: text   (%s)
%   column2: double (%f)
%	column3: double (%f)
%   column4: double (%f)
%	column5: double (%f)
%   column6: double (%f)
%	column7: double (%f)
%   column8: text (%s)
%	column9: double (%f)
%   column10: double (%f)
%	column11: double (%f)
%   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)
% For more information, see the TEXTSCAN documentation.
formatSpec = '%s%f%f%f%f%f%f%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%[^\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, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(1)-1, 'ReturnOnError', false);
for block=2:length(startRow)
    frewind(fileID);
    dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines', startRow(block)-1, 'ReturnOnError', false);
    for col=1:length(dataArray)
        dataArray{col} = [dataArray{col};dataArrayBlock{col}];
    end
end

%% 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
L1b.t_utc  = dataArray{:, 1};
L1b.t_unix = dataArray{:, 2};
L1b.t_sclk = dataArray{:, 3};
L1b.t_tid = dataArray{:, 4};
L1b.TID = dataArray{:, 5};
L1b.UMKID = dataArray{:, 6};
L1b.orbit = dataArray{:, 7};
L1b.fmode = dataArray{:, 8};
L1b.multi = dataArray{:, 9};
L1b.fil = dataArray{:, 10};
L1b.Temp_s = dataArray{:, 11};
L1b.mass = dataArray{:, 12};
L1b.counts = dataArray{:, 13};
L1b.cps_raw = dataArray{:, 14};
L1b.cps_raw_bkgd = dataArray{:, 15};
L1b.cps_dt = dataArray{:, 16};
L1b.cps_dt_bkgd = dataArray{:, 17};
L1b.bkgd = dataArray{:, 18};
L1b.alt = dataArray{:, 19};
L1b.Vsc = dataArray{:, 20};
L1b.RAM1 = dataArray{:, 21};
L1b.RAM2 = dataArray{:, 22};
L1b.SOLlon = dataArray{:, 23};
L1b.SOLlat = dataArray{:, 24};
L1b.LST = dataArray{:, 25};
L1b.X = dataArray{:, 26};
L1b.Y = dataArray{:, 27};
L1b.Z = dataArray{:, 28};
L1b.VX = dataArray{:, 29};
L1b.VY = dataArray{:, 30};
L1b.VZ = dataArray{:, 31};
L1b.LAT = dataArray{:, 32};
L1b.LONG = dataArray{:, 33};
L1b.SZA  = dataArray{:, 34};

