Link to home
Start Free TrialLog in
Avatar of salamay
salamayFlag for United States of America

asked on

creating variables with colheaders after Matlab importdata

Hi,

After importing a tab delimited file into matlab using the importdata function i get my headers in one cell array (textdata or colheaders) and the numerical data in data matrix.

I want to create variables from the first four letters of  each column header with the corresponding data in the data matrix. Is is possible. Please help!

Thanks
Salamay
Avatar of salamay
salamay
Flag of United States of America image

ASKER

this is how i did it and it worked

check this link for more info http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
varnames = colheaders;
for i=1:length(colheaders)
    s.(varnames{i})= data(:,i);
end

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial