Effacer les filtres
Effacer les filtres

taking 2 columns from two different matrices and making a new 2 column matrix

6 vues (au cours des 30 derniers jours)
help!! I have 2 different matrices a and b with large sample sizes, i need to take the first column from b and put it into the first column in a new matrix c and take the first column from a and put it into column 2 in matrix c ??
I know theres a simple answer to this, its just every bit of info on this topic just shows when there are small sample sizes! any help regarding this topic would be greatly appreciated

Réponse acceptée

singh
singh le 25 Avr 2015
c=b(:,1);
d=a(:,1);
C=cat(2,[c,d]);

Plus de réponses (1)

dpb
dpb le 27 Avr 2015
Write it in one step...
c=[b(:,1) a(:,2)];
"... every bit of info on this topic just shows when there are small sample sizes"
Size is totally irrelevant other than the two must be concordant in size in the direction of concatenation (iow, here they must be the same length). An example that demonstrates a principle for a vector length of 3 is just as useful as one of 3 million; just that one can actually visualize the smaller so as a pedagogical tool it is far preferable, in fact.

Catégories

En savoir plus sur Creating and Concatenating Matrices 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