MATLAB: Extracting data from cell array

cell array structMATLAB

Let's say that i have
data =
1×4 cell array
{12×1 cell} {12×1 cell} {12×1 int32} {12×1 int32}
first 12×1 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.

Best Answer

It would help you to learn about tables, which are more appropriate in this case than cell arrays:
% Original cell array:
data = {{'Smith' ; 'Gold'}, {'Ann' ; "Agnes"}, {'22' ; '24'}, {'1' ; '2'}}
% Convert cell array into table:
t = table(data{1}, data{2}, data{3}, data{4}, ...
'VariableNames', {'LastName', 'FirstName', 'Age', 'IDNumber'})
% Get out row 1:
a = t(1, :)
% Get out row 2:
b = t(2, :)