function cl31 = import_cl31(filename) % import_cl31 - Imports CL31 files logger with standard flux logging % system. Files are saved as cell array of character strings % % import_cl31(filename) % % INPUT % filename - name of .CL file to read in (str) % % JZP November 2018 %% Initialize variables. % filename = '/Volumes/AO2018/raw/mast/180901_100000.00.CL'; delimiter = ' '; %% Format string for each line of text: % column1: double (%s) % column2: double (%s) % column3: double (%s) % column4: double (%s) % column5: double (%s) % column6: double (%s) % column7: text (%s) % column8: text (%s) % column9: text (%s) % column10: text (%s) % column11: text (%s) % column12: text (%s) % column13: text (%s) % column14: text (%s) % column15: text (%s) % column16: text (%s) % For more information, see the TEXTSCAN documentation. formatSpec = '%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%[^\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, 'MultipleDelimsAsOne', true, '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 cl31.VarName1 = dataArray{:, 1}; cl31.VarName2 = dataArray{:, 2}; cl31.VarName3 = dataArray{:, 3}; cl31.VarName4 = dataArray{:, 4}; cl31.VarName5 = dataArray{:, 5}; cl31.VarName6 = dataArray{:, 6}; cl31.VarName7 = dataArray{:, 7}; cl31.VarName8 = dataArray{:, 8}; cl31.VarName9 = dataArray{:, 9}; cl31.VarName10 = dataArray{:, 10}; cl31.VarName11 = dataArray{:, 11}; cl31.VarName12 = dataArray{:, 12}; cl31.VarName13 = dataArray{:, 13}; cl31.VarName14 = dataArray{:, 14}; cl31.VarName15 = dataArray{:, 15}; cl31.VarName16 = dataArray{:, 16}; % %% Clear temporary variables % clearvars filename delimiter formatSpec fileID dataArray ans;