explain the logic please
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Bob Matthews
il 30 Ott 2021
Modificato: Bob Matthews
il 30 Ott 2021
0 voti
2 Commenti
Walter Roberson
il 30 Ott 2021
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
il 30 Ott 2021
Modificato: Bob Matthews
il 30 Ott 2021
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!