필터 지우기
필터 지우기

extracting field name and values from a struct.

조회 수: 35 (최근 30일)
Matthew Wilson
Matthew Wilson 2018년 11월 2일
편집: MFK 2023년 1월 16일
Hi all,
I have files produced by a piece of research equipment and each file comes up as 1x1 struct with 65 fields. I am interested in getting the field name and corresponding values from only six of these, each field is named and not numbered.
Is there a way of getting Matlab to provide just the filenames and values of the six I am after?
Thanks!
MJ

답변 (2개)

madhan ravi
madhan ravi 2018년 11월 2일
See getfield() might be the one you’re looking for.

MFK
MFK 2023년 1월 16일
편집: MFK 2023년 1월 16일
fn=fieldnames(out);
for jj=1:size(fieldnames(YOUR_STRUCT),1)
features1(1,jj)=YOUR_STRUCT.(fn{jj});
end

카테고리

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