place different sets of columns into a matrix

2 views (last 30 days)
Hello all!
I multiple sets of column vectors (with different values) some are a size of 400x5 and others are a size of 400x1 all with different values in their rows. I wish to put all them along each other in one matrix (i.e. to form a matrix of 400x(n5+m1). I don't want any of the individual colmuns to be effected by one another, would just like them to "line up" in one big matrix.
I have tried D = [ A B C D a b c d] (capital are the 400x5, lower case is 401x1) and that is the order I'd like them to line up but it doesn't seem to be working? Any help would be much appreciated!
  2 Comments
Rashed Mohammed
Rashed Mohammed on 19 Mar 2021
Hi Tanner,
Unless the 401 in your 2nd paragraph isn't a typo, I would expect what you are doing should work. Can you share what error you are seeing and if possible minimal data to reproduce the issue
Tanner D Whatley
Tanner D Whatley on 19 Mar 2021
I ended up scrapping the original coding for a for loop process that ended up being much easier to manage. But no it wasn't a typo, I just wasn't writing the code properly. Thank you for the concern!

Sign in to comment.

Answers (1)

the cyclist
the cyclist on 19 Mar 2021
As you can see below, what you tried will work.
N = 400;
A = rand(N,5);
B = rand(N,5);
C = rand(N,5);
D = rand(N,5);
a = rand(N,1);
b = rand(N,1);
c = rand(N,1);
d = rand(N,1);
output = [A B C D a b c d];
size(output)
ans = 1×2
400 24
As @Rashed Mohammed mentioned, please tell us the full error message, and upload the data if you can. Also, are all your data numeric? You'll need to use cell arrays or some other data type, if you are mixing numeric and text data.
  1 Comment
Tanner D Whatley
Tanner D Whatley on 19 Mar 2021
I ended up scrapping the original coding for a for loop process that ended up being much easier to manage. But no it wasn't a typo, I just wasn't writing the code properly. Thank you for the concern! and that looks like it would work, thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!