How do I import an excel file using code so that I am creating a vector with each column using the column names?
Show older comments
When importing an excel file you can generate a function to import the file in code. This generated function however puts the data in a matrix. I need my data as column vectors. I do not wish to have to import manually every single time as I have many datasets.
If I save my file as a .txt instead of excel, and bring it in using the other wizard, it will not let me click on the 'create a vector with each column using the column names'. Its grey and not an option. I know this method has a generate code box you can click, so I do not have to do the code myself.
Does anyone know how i can import not manually?
Thanks
Answers (1)
Once you import as a matrix, you can distribute the columns to different variables by doing
Mcell=num2cell(YourMatrix,1);
[Column1,Column2,Column3,...]=deal(Mcell{:});
Categories
Find more on Spreadsheets in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!