Extract rows of matrices with nearest days record

1 vue (au cours des 30 derniers jours)
Poulomi Ganguli
Poulomi Ganguli le 11 Sep 2017
Hello, I am re-editing my question once again. I have two matrices as attached. Both have different sizes and 1st, 2nd, 3rd, & 4th value show year, month, day and values in both matrices. I need to extract rows with same year and month however, day of +/-6 days from matrix A and relative to days from matrix B. If two or more days are close in matrices A & B, I should choose the rows corresponding to highest value from both matrices. For example, for the attached matrices the expected output is:
1954 12 22 2,7411 1954 12 28 774
1959 1 3 1,7784 1959 1 10 421
1959 1 24 1,1871 1959 1 24 419
1960 12 4 1,7213 1960 12 8 829
1962 2 12 2,1813 1962 2 15 628
1966 12 24 1,8173 1966 12 27 802
1968 1 15 1,6567 1968 1 17 981
Any help how to code this?

Réponses (1)

KSSV
KSSV le 12 Sep 2017
Modifié(e) : KSSV le 12 Sep 2017
doc ismemeber and ismmebrtol for year and month use ismemeber and for days you can use ismemebrtol. It is an easy task.
  1 commentaire
Poulomi Ganguli
Poulomi Ganguli le 12 Sep 2017
Modifié(e) : Poulomi Ganguli le 12 Sep 2017
ismembertol checks within tolerance limit set by eps. I am not sure how to apply here for my data. I could match year and months using below code:
[~, Matched1_dayYr, Matched2_dayYr] = intersect(A(:, [1:2]), B(:, [1:2]),'rows');
M1_dayYr = A(Matched1_dayYr,[1:4]);
M2_dayYr = B(Matched2_dayYr,[1:4]);
Z1 = [C1 C2];
I found something here: https://www.mathworks.com/matlabcentral/answers/215440-can-you-set-the-tolerance-for-ismembertol-as-a-percentage
however, they are also in decimals.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by