comparing the variables of values of two tables

28 次查看(过去 30 天)
I am having the following problem, we have two tables t1 and t2 (an in the attachments), we would like to do the following comparison between them
  • - compare two dates values in the tables (using the variables t1.Date3 and t2.date2)., we extract only the matching rows and save them in another table.
  • -Then using the saved table we compare the minutes of the two times in the two tables, we choose the row were only the minutes from the second table falls within +-30mins of the minutes from the first table.
  • -Then we check if the f0f2 variable for the second table lies within a range of +-0.5 of the f0f2 variable in the first table. then again we remove any non matching rows from the table.
I started off by doing the follwoing but i am not sure if I am doing it in the right way,
%comparing the dates values from t1 and t2
[Lia2, Locb2] = ismember(t1.Date3, t2.date2);
indx2 = Locb2(Locb2 > 0);
t3=t1(Lia2,:);
tlower=t2.date(indx2)-minutes(30);
tupper=t2.date(indx2)+minutes(30);
%comparing the times of th two tables based on the minutes value
tf = isbetween(t2.date(indx2),tlower,tupper);
t3=t3(tf,:);
%comparing the f0F2 values
tf2=isbetween(t2.foF2(indx2),t2.foF2(indx2)-0.5,t2.foF2(indx2)+0.5);
t3=t3(tf2,:);

回答(1 个)

Tala
Tala 2022-4-3
编辑:Tala 2022-4-3
are you sure there is any matching numbers in variables t1.Date3 and t2.date2? Lia2 is an array of 0!
  2 个评论
Manar Anwar
Manar Anwar 2022-4-3
I have change the attachement t2 to another table where I am sure there is a matching in the dates, but still lia2 is an array of 0, thats why I am not sure if I am doing things correctly
Tala
Tala 2022-4-4
The values in t1.Date3 are identical and equal to 1.9961e+11! you can use
[row,~] = find(t2.date2==t1.Date3(1));
to find the rows that are equal to 1.9961e+11. The rows 57988,57989, 57990, 57991match t1.Date3. The Newt2 has only 4 rows.
Newt2=t2(row,:);
I am not clear what you wanna do from this point. To my understaning, t2.date is a constant value for the most part as you can see below! adding 30 minutes to t2.date does not make sense to me :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by