find common timestamp of two different matrix
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohan kand
el 24 de Jul. de 2023
Comentada: Mohan kand
el 26 de Jul. de 2023
I have two kinds of data heat production (HP) and temperature. Both data have timestamp values in the first column and second column include HP and temperature values. The size of both data is unequal. Firstly I want to match the timestamp of HP with the timestamp of temperature and than create a third column that include the HP values with the matched timestamp of the temperature, while making unmatched values zeros. See the attached images and data as mat file.
data 1:
data 2:
Output I want :
0 comentarios
Respuesta aceptada
C B
el 24 de Jul. de 2023
Editada: C B
el 24 de Jul. de 2023
% Load Mat file in Base Workspace
load("data.mat")
% Convert the timestamps to strings, including only up to the minute
Temperature.Timestamp_temp = cellstr(datetime(Temperature.Timestamp_temp,'Format','yyyy-MM-dd HH:mm'));
HP.Timestamp_HP = cellstr(datetime(HP.Timestamp_HP,'Format','yyyy-MM-dd HH:mm'));
% Initialize the new table from the Temperature table
new_table = Temperature;
% Add a new column for HP, initializing with zeros
new_table.HP = zeros(height(new_table), 1);
% Fill in the HP data where the times match
[~, idx1, idx2] = intersect(new_table.Timestamp_temp, HP.Timestamp_HP);
new_table.HP(idx1) = HP.Var2(idx2);
disp(new_table(1:50,:));
Please let me know if it is working as per expected or not.
also let me know if any part you didnt understood.
4 comentarios
C B
el 26 de Jul. de 2023
Editada: C B
el 26 de Jul. de 2023
@Mohan kand It does Exist Please check below!
% Load Mat file in Base Workspace
load("data.mat")
disp(HP(16150:16155,:));
Más respuestas (0)
Ver también
Categorías
Más información sobre Oil, Gas & Petrochemical 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!