comparing the variables of values of two tables
18 ビュー (過去 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,:);
0 件のコメント
回答 (1 件)
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 件のコメント
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 :)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/952289/image.jpeg)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!