find common timestamp of two different matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
C B
le 24 Juil 2023
Modifié(e) : C B
le 24 Juil 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 commentaires
C B
le 26 Juil 2023
Modifié(e) : C B
le 26 Juil 2023
@Mohan kand It does Exist Please check below!
% Load Mat file in Base Workspace
load("data.mat")
disp(HP(16150:16155,:));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Oil, Gas & Petrochemical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!