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

6 次查看(过去 30 天)
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

采纳的回答

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

更多回答(1 个)

dpb
dpb 2015-4-27
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by