How do I import an excel file using code so that I am creating a vector with each column using the column names?

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{:});

Products

Asked:

on 13 Oct 2012

Community Treasure Hunt

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

Start Hunting!