set(0,'defaultaxesfontsize',20);set(0,'defaultlinelinewidth',2);set(0,'defaultaxesfontname','times new roman');
clear
close all

%------------------------inputs--------------------------------------------
file_path='YOUR PATH NAME'; % PLEASE ENTER YOUR PATH
file_name='Your FILE NAME'; % PLEASE ENTER YOUR FILE NAME

%-------------------------read the datalogger file-------------------------
%Timestring --> Time in string format
%Trash --> Sample number
%Batteryvolt --> Voltage of Battery (V)
%Rnet --> Net radiation from NR-LITE radiometer (W/m2)
%Sonic1 --> Lower CSAT (first column->u(m/s), second column->v(m/s), 
%                       third column->w(m/s), foruth column->T(0C))
%Sonic2 --> Upper CSAT (same column definition as Sonic1)
[Timestring,Trash,Batteryvolt,Rnet,Sonic1(:,1),Sonic1(:,2),Sonic1(:,3),Sonic1(:,4),Sonic2(:,1),Sonic2(:,2),Sonic2(:,3),Sonic2(:,4)]=...
    textread(strcat(file_path,file_name),'%23c%u%f%f%f%f%f%f%f%f%f%f','delimiter',',','headerlines',4);

%----------------------conversion of time----------------------------------
Timestring(Timestring(:,21)=='"',:)=strcat(Timestring(Timestring(:,21)=='"',1:20),'.0"'); % quality control of time string
Time=datenum(str2num(Timestring(:,2:5)),str2num(Timestring(:,7:8)),str2num(Timestring(:,10:11)),...
    str2num(Timestring(:,13:14)),str2num(Timestring(:,16:17)),str2num(Timestring(:,19:22))); % time conversion