Combining consecutive vectors into a matrix
Mostrar comentarios más antiguos
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 comentarios
Guillaume
el 2 de Oct. de 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
el 2 de Oct. de 2019
Guillaume
el 2 de Oct. de 2019
But you do you get then into matlab? Are they already saved in a mat file?
Lars Bouten
el 2 de Oct. de 2019
Respuesta aceptada
Más respuestas (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.
Categorías
Más información sobre Spreadsheets en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!