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

18 views (last 30 days)
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

Accepted Answer

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

More Answers (1)

dpb
dpb on 27 Apr 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.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!