MATLAB: Create a difference vector of time

columndifferencetimevector

I have a matrix of times (HH:MM:SS) : the first column is the start-time and the second is the stop-time. I can extract each columns as:
fileID=fopen('Times.txt');
A = textscan(fileID,'%D %D');
start=A{1};
stop=A{2};
and now I want to create a new column vector with the subtraction between the start-time and the stop-time of each rows. With this new vector I will create a Histogram. So how can I create the difference vector??
Thanks
Michela

Best Answer

How about:
A = readtable('Times.txt', 'Delimiter','\t','ReadVariableNames',false, 'datetime', 'text')
startTimes = A{:,1}
stopTimes = A{:,2}
elapsedTimes = etime(datevec(stopTimes), datevec(startTimes))