how to merge 2 variable of different size?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how to merge 2 variable of different size? where size of A is 1X5 'double' and size of B is 2X10 'double'.
A = [1,2,3,4,5] '1 x 5 double'
b = [6 7
8 9
10 11
12 13
14 15
16 17
18 19
20 21
22 23
24 25]
0 commentaires
Réponses (1)
dpb
le 3 Nov 2021
With what expected as result, pray tell?
You can't have a 2-column matrix of 25-elements; you could keep the two as elements in a cell array (not particularly recommended, but possible, and the choice if there's going to be a need to identify those elements from A again later).
C=[A(:);b(:)];
returns a column vector; you can reshape() it by prime factors if wanted.
Alternatively, one could augment and reshape the first to have two columns -- but that will require A having an even number of elements to do so, either by adding (or removing) an odd number first.
C=[reshape([0 A],2,[]);b];
is one possible solution of any number in that vein.
0 commentaires
Voir également
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!