Extracting data from cell array
Show older comments
Let's say that i have
data =
1×4 cell array
{12×1 cell} {12×1 cell} {12×1 int32} {12×1 int32}
first 12x1 cell array contains Names, second sournames, third age and forth id numer.
I would like to do something like extract just 1st elements from each cell array - it woul'd give me an array of data for one person, then do it for the next 11 rows.
How to make it? It should be convert into struct, and I know that repmat function can be useful here, but i have no clue how to do it.
1 Comment
KSSV
on 29 Nov 2020
You can convert cell to structure or table using cell2struct and cell2table. Read about them and then it should be easy to follow.
Accepted Answer
More Answers (1)
KSSV
on 29 Nov 2020
T = cell2table(C,...
'VariableNames',{'Name' 'SirName' 'Age' 'Id'}) ;
T
You have the data in Table T, you can extract what you want.
Categories
Find more on Data Type Conversion 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!