Upload txt file with time units
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I have a text file like,
13:43:51 26.0503 0.0000060763786
13:43:51 26.0503 0.0000085937353
13:43:51 26.0503 0.0000073350570
13:43:51 26.0503 0.0000073350570
13:43:52 26.0503 0.0000084201246
13:43:52 26.0503 0.0000072482512
13:43:52 26.0503 0.0000076388760
13:43:52 26.0503 0.0000093315811
13:43:52 26.0503 0.0000073350570
I would like to upload the time difference from the beginning, such as
1 26.0503 0.0000060763786
1 26.0503 0.0000085937353
1 26.0503 0.0000073350570
1 26.0503 0.0000073350570
2 26.0503 0.0000084201246
etc.,..
That is have the time display in seconds only. Any idea how to do this.
When using x = load('data.txt');
I get
14.0000 24.9678 0.0008
14.0000 24.9678 0.0008
14.0000 24.9678 0.0008
14.0000 24.9678 0.0008
14.0000 24.9678 0.0008
14.0000 25.0020 0.0008
It seems to only take the first number.
Kind Regards,
That is I want to upload a vector of hh:mm:ss and then convert it to seconds.
0 comentarios
Respuestas (1)
Walter Roberson
el 24 de Mayo de 2013
fid = fopen('data.txt','rt');
datacell = textscan(fid, '%s%f%f');
fclose(fid);
datatimes = datenum(datacell{1}, 'hh:mm:ss');
timeoffset = datatimes - datatimes(1);
offsetsecs = round(timeoffset * 24*60);
newdata = [offsetsecs(:), datacell{2}, datacell{3}];
newdata will now be the array.
1 comentario
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!