Combine many vectors into one matrix (quickly!)

7 views (last 30 days)
Nick
Nick on 13 Oct 2012
Hi guys. I have over 100 column vectors (all of the same length) that I would like to combine side-by-side into one matrix. I'm not sure how to do this in a loop. The vectors have names that are somewhat common among them. For example, their names take the form: "x_yyyyy", where x is a letter and there are 6 different values of x, and y is five digits, and there are 18 values of y. (So I have 6x18=108 vectors). E.g., I have C_02011, C_02012, H_02513, etc... So it might be possible to combine these using a loop with some sort of wildcarding, but I'm not really sure how to do this. Basically, I'm looking for a way to create one big array with all of these vectors without having to have lines of code going column by column. Meaning, A(:,1)=vector1, A(:,2)=vector2......A(:,108)=vector108 is NOT what I want to do!!
These 108 vectors are all that I have in my workspace, so maybe there's a way to just combine everything I have in my workspace into a matrix?
The actual goal of this question is to be able to export these columns into Stata. I thought if I had one big matrix, I could do xlswrite into Excel, then open this spreadsheet in Stata, but if there's a more direct way to take these 108 columns and quickly get them into Stata, that would be great to know!
Thanks for the input.

Answers (1)

Walter Roberson
Walter Roberson on 13 Oct 2012

Community Treasure Hunt

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

Start Hunting!