Effacer les filtres
Effacer les filtres

How can I combine two double arrays into one but in different rows and columns within Matrix

11 vues (au cours des 30 derniers jours)
So, for example, I have a matrix that is
A = [0;0;0;1;1;1;2;2;2]
A = 9×1
0 0 0 1 1 1 2 2 2
and
B = [5,6,7,8;1,2,3,4;0,1,2,3]
B = 3×4
5 6 7 8 1 2 3 4 0 1 2 3
and I want the result to be
C = [0,6;0,7;0,8;1,2;1,3;1,4;2,1;2,2;2,3]
C = 9×2
0 6 0 7 0 8 1 2 1 3 1 4 2 1 2 2 2 3
Is there a simple way to do this?
Thanks

Réponse acceptée

Matt J
Matt J le 28 Août 2023
Modifié(e) : Matt J le 28 Août 2023
A = [0;0;0;1;1;1;2;2;2];
B = [5,6,7,8;1,2,3,4;0,1,2,3];
b=B(:,2:end)';
C=[A(:),b(:)]
C = 9×2
0 6 0 7 0 8 1 2 1 3 1 4 2 1 2 2 2 3

Plus de réponses (0)

Catégories

En savoir plus sur Data Types 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