explain the logic please
显示 更早的评论
Hi
Here is a small piece of code (3rd party)
*************************************************
function A = TR1_4_CountTime(DCA,Time)
% calculate time differences between each row
for i=1:length(DCA)-1
A(i) = 0 ;
for j=DCA(i)+1:DCA(i+1)
A(i) = A(i) + Count(Time{j},Time{j-1}) ;
end
end
end
function s = Count(time1,time2)
if ~isequal(time1(1:2),time2(1:2)) % if data are not in the same day,
% set default time gap as 1 millisecond
t1=datenum(time1(find(time1==',')+1:end),'HH:MM:SS')+1;
t2=datenum(time2(find(time2==',')+1:end),'HH:MM:SS');
s=round((t1-t2)*24*60); % for minute data
return ;
else % if data are in the same day, calculate time difference
t1=datenum(time1(find(time1==',')+1:end),'HH:MM:SS');
t2=datenum(time2(find(time2==',')+1:end),'HH:MM:SS');
s=round((t1-t2)*24*60); % for minute data
end
end
************************************************************
please can somebody explain what the author is trying to do ?
Bob M
采纳的回答
更多回答(1 个)
Bob Matthews
2021-10-30
编辑:Bob Matthews
2021-10-30
0 个投票
2 个评论
Walter Roberson
2021-10-30
In the extract you posted, as outside observers we do not have enough information to know what order the date/times were extacted from the file and stored into the Time array, and we also do not know what DCA is about.
Bob Matthews
2021-10-30
编辑:Bob Matthews
2021-10-30
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!