Access data in cell and save as vector with corresponding variable name

1 view (last 30 days)
hey there,
i am creating a cell with tables in it when i read a mf4 file. (see picture 1)
Thats the structure of each table (picture 2):
I can access each variable easily with the brackets and save them with the wanted name.
However I want to automate it.
For instance search for d2s and get the values out of the table and save it in a vector in double format with the vector named after the variable.
t does not need to be extracted.
Thanks in advance! HMU if you need more!

Sign in to comment.

Accepted Answer

Jan on 29 Sep 2022
Edited: Jan on 29 Sep 2022
Data = struct(); % [EDITED], was: struct([]);
for k = 1:numel(tableCell)
C = tableCell{k};
NameList = T.Properties.VariableNames;
NameList = setdiff(NameList, {'t'}); % Ignore "t"
for iName = 1:numel(NameList)
Name = NameList{iName};
Data.(Name) = C.(Name);

Sign in to comment.

More Answers (0)


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