how to create matrix based on column conditions

2 vues (au cours des 30 derniers jours)
Poulomi Ganguli
Poulomi Ganguli le 22 Août 2018
Commenté : Poulomi Ganguli le 22 Août 2018
Hello I have two different matrices A and B as below:
A=
9 16 1966 65.3
9 16 1967 73
9 16 1968 78.9
12 23 1966 61
12 23 1967 63.2
12 23 1968 51.8
12 28 1966 0
12 28 1967 0
12 28 1968 0
12 29 1966 0
12 29 1967 0
12 29 1968 0
B =
1 16 919.3254136
1 23 3979.074644
1 28 3582.388628
1 29 8401.61424
I need to create a third matrix C, which will take the value from Matrix A and fill the corresponding value at Matrix B in the form of time series/ the combination of both matrices
C =
1 16 919.3254136 1966 65.3
1 23 3979.074644 1966 61
1 28 3582.388628 1966 0
1 29 8401.61424 1966 0
1 16 919.3254136 1967 73
1 23 3979.074644 1967 63.2
1 28 3582.388628 1967 0
1 29 8401.61424 1967 0
1 16 919.3254136 1968 78.9
1 23 3979.074644 1968 51.8
1 28 3582.388628 1968 0
1 29 3582.388628 1968 0
I am trying with ismember but could not able to make it. Any help?

Réponse acceptée

Matt J
Matt J le 22 Août 2018
Modifié(e) : Matt J le 22 Août 2018
C=innerjoin(array2table(B),array2table(A),'LeftKeys','B2','RightKeys','A2')
and then use table2array(), if needed.

Plus de réponses (0)

Catégories

En savoir plus sur Cell Arrays 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