Hi Guys,
I have two arrays in the datetime format. 1 array with the starting points of an event, a 2nd array with the end points of the same event. Using the "between" function I have determined the times between the start and end of each event. Now resulting in 1 array with calendarDuration values.
My goal is to find the total duration, thus summing up all values in the calendarDuration array. However… The sum function does not work for this format, see the code resulting in the error below. Any help on how to sum up the values with calendarDuration format?
Error using sum
Invalid data type. First argument must be numeric or logical.
threshold=1.5;exceed_RH=Druk_RH>1.5; %logical array for threshold exceedance
difference_RH=diff(exceed_RH);start_operation_RH=difference_RH==1;time_start_operation_RH=time(start_operation_RH); % Returns array with datetimes of start of operation
end_operation_RH=difference_RH==-1;time_end_operation_RH=time(end_operation_RH); %Returns array with datetimes of end of operation
dt=between(time_end_operation_RH,time_start_operation_RH); %time between start and end, calendarDuration format
total_uptime_RH=sum(dt)
Best Answer