Create the matrix with aligned dates
Mostrar comentarios más antiguos
hi,i've this problem to solve
i've a matrix of date (see pics) A (row) * B(columns)
i used datetime in this matrix

Each date vector can start and end at a different time
I want to synchronize the dates so that each row corresponds to the same date (
example:

Or if it becomes complicated to shift them up or down n boxes, place them side by side with an index (see pics below)

6 comentarios
the cyclist
el 4 de Jun. de 2023
Can you upload the data, instead of using screenshots? You can use the paper clip icon in the INSERT section of the toolbar.
shamal
el 4 de Jun. de 2023
shamal
el 4 de Jun. de 2023
shamal
el 6 de Jun. de 2023
Movida: the cyclist
el 6 de Jun. de 2023
Respuestas (1)
load SyncronizedData.mat
for nc = 2:width(J)
[tf,loc] = ismember(J(:,nc),J(:,nc-1));
tmp = J(:,nc);
J(:,nc) = {'NaT'};
J(loc(tf),nc) = tmp(tf);
end
J(all(strcmp(J,'NaT'),2),:)=[]
2 comentarios
shamal
el 7 de Jun. de 2023
the cyclist
el 7 de Jun. de 2023
I'm not sure why you save something different in the file you upload than you did in the file you are using. But, yes, it looks like J.J should work.
Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

