Combining consecutive vectors into a matrix
Show older comments
I am trying to combine 108 consecutive vectors (100x1 double) into a matrix in such a way that I will get a 100x108 matrix. The vectors are called like HH_1, HH_2, etc., so I can do it by using M=[HH_1,HH_2,...], but this is really a lot of work for 108 vectors. Therefore, I was wondering if there is a short and easy way to perform this action. After I obtain the 100x108 matrix, I want to seperate this matrix into 100 rows, how can I do this easily?
4 Comments
Guillaume
on 2 Oct 2019
but this is really a lot of work for 108 vectors.
Indeed, and so it must have been a lot of work to create these HH_1, HH_2. The simple solution is not to create numbered variables in the first place. The code that created these variables is what needs fixing. Can you show it?
Lars Bouten
on 2 Oct 2019
Guillaume
on 2 Oct 2019
But you do you get then into matlab? Are they already saved in a mat file?
Lars Bouten
on 2 Oct 2019
Accepted Answer
More Answers (1)
You must have changed the options of the wizard to specifically create variables from the columns of the excel spreadsheet. Don't do that. Import the data as a table (best), or cell array and your problem will go away.
Or better, don't use the import wizard. Use readtable, readmatrix (if on a version new enough) or xlsread.
Obtaining your M matrix may be as simple as :
M = readmatrix(yourexcelfile);
If not, an example file would help us understand better.
Categories
Find more on Spreadsheets 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!