I want to convert array to table and add labels too.

2 views (last 30 days)
I have 2000 columns in cell array.i want to have labels 'one' for first 10 columns and then labels 'two' for next ten columns. How to convert to table with labels as mentioned??

Answers (1)

Walter Roberson
Walter Roberson on 24 Jul 2018
You can only merge into single variables if all of the values being merged are the same data type. As you want to do this for each group of 10 columns, that suggests that your columns are all the same data type, which leads us to question why you are using a cellarray instead of a numeric array.
  2 Comments
haider mehraj
haider mehraj on 24 Jul 2018
I am not using cellarray..data is as numeric array..
Walter Roberson
Walter Roberson on 24 Jul 2018
varnames = {'one', 'two', 'three', ....};
t = table();
for group = 1 : length(varnames)
t.(varnames{group}) = YourArray(:,(group-1)*10+1:group*10);
end

Sign in to comment.

Categories

Find more on Tables 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!