find common timestamp of two different matrix
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohan kand
am 24 Jul. 2023
Kommentiert: Mohan kand
am 26 Jul. 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 Kommentare
Akzeptierte Antwort
C B
am 24 Jul. 2023
Bearbeitet: C B
am 24 Jul. 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 Kommentare
C B
am 26 Jul. 2023
Bearbeitet: C B
am 26 Jul. 2023
@Mohan kand It does Exist Please check below!
% Load Mat file in Base Workspace
load("data.mat")
disp(HP(16150:16155,:));
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Oil, Gas & Petrochemical finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!