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

조회 수: 1 (최근 30일)
Dennis
Dennis 2022년 9월 27일
댓글: Dennis 2022년 9월 30일
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!
  댓글 수: 4
Jan
Jan 2022년 9월 29일
Did you read the link? You find the "bad solution" there also as deprecated method, because it causes more trouzbles as it solves. But of course, if you really want to apply this, do it.
Dennis
Dennis 2022년 9월 29일
Could you then help me with creating the struct?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2022년 9월 29일
편집: Jan 2022년 9월 29일
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);
end
end
  댓글 수: 3

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by