How to add names to table variables from a large cell with names?
2 views (last 30 days)
Show older comments
Hello,
I have a 600x1000 array (double), where Columns have data like this...
145.65 18.81 29.06 28.48 ...
145.66 18.73 29.10 28.52 ...
145.64 18.77 29.02 28.49 ...
...
145.82 17.59 29.27 28.94 ...
And have a 600 x 1 cell with Names like...
AAA_010
AAA_002
AAA_143
...
AAA 123
And I would like to end with a TABLE that has variable names based on the above cell with Names, like this...
AAA_010 AAA_002 AAA_143 ... AA123
145.65 145.66 145.64 ... 145.82
18.81 18.73 18.77 ... 17.59
29.06 29.10 29.02 ... 29.27
28.48 28.52 28.49 ... 28.94
... ... ... ... ...
Thanks for your suggestions!
0 Comments
Accepted Answer
dpb
on 22 Sep 2017
Edited: dpb
on 22 Sep 2017
Looks peculiar orientation as doesn't keep the similarly-valued variables together, but per your request--
>> t=array2table(d.','variablenames',n)
t =
AAA_010 AAA_002 AAA_143 AAA_123
_______ _______ _______ _______
145.65 145.66 145.64 145.82
18.81 18.73 18.77 17.59
29.06 29.1 29.02 29.27
28.48 28.52 28.49 28.94
>>
Also, those names are going to be very difficult to use in being only distinguished by the trailing digits unless it is intended that names be automatically generated and/or the column positions are known. Of course, with 600 variables, having individual names/variables is going to be an issue in and of itself.
I'd suggest probably keeping the array structure and using the vector operations possible in Matlab will be more fruitful way to process your data but we're not given any indications of what intend to do next.
More Answers (0)
See Also
Categories
Find more on Logical 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!