merge date time

4 visualizzazioni (ultimi 30 giorni)
Tiina
Tiina il 3 Feb 2012
How can I merge the two columns together (into one) and generate a date time number for data like
20101229 154907
20101229 154908
20101229 154908
20101229 154909
20101229 154909
20101230 93001
20101230 93001
20101230 93004
and a result like
2010229154907 for row 1
2010229154907 for row 2 and so on
dates and times are doubles
thanks

Risposte (3)

Walter Roberson
Walter Roberson il 3 Feb 2012
Do not accumarray() using these numbers as the subscripts. Instead,
Mu = unique(mergedtimes);
[tf, Muidx] = ismember(mergedtimes, Mu);
Then uses MuIdx(:) as the subscript for accumarray() purposes. Afterwards, you can map back row K of your accumarray results to time value Mu(K)
  3 Commenti
Walter Roberson
Walter Roberson il 4 Feb 2012
mod(mergedtime, 1000000) to get the time data,
fix(mergedtime ./ 1000000) to get the data data.
Tiina
Tiina il 4 Feb 2012
yea awesome

Accedi per commentare.


Walter Roberson
Walter Roberson il 3 Feb 2012
mergedtimes = data(:,1) * 1000000 + data(:,2);

James Tursa
James Tursa il 3 Feb 2012
If X is your original M x 2 data:
X(:,1)*1000000 + X(:,2)
  1 Commento
Tiina
Tiina il 3 Feb 2012
I tried before posting a q and bec I am using accumarray at one point in the code am running out of memory. When I did not merge the columns (that is accumarray by either columns) i didn not run out of memory so i though that merging by multiplying by a number would be related to the issue ..
is there any tip for this case?

Accedi per commentare.

Categorie

Scopri di più su Time Series Objects in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by