필터 지우기
필터 지우기

convert array in a struct

조회 수: 1 (최근 30일)
elisa ewin
elisa ewin 2017년 3월 20일
편집: Greg Dionne 2017년 3월 20일
Hi,
I want to trasform the array in the file attached in a struct; I have used cell2struct but it doesn't run: can you help me?

채택된 답변

Greg Dionne
Greg Dionne 2017년 3월 20일
편집: Greg Dionne 2017년 3월 20일
You didn't give us the fieldnames you wanted. So I'm going to guess you want them as 'thing1', 'thing2', 'thing3', etc. and assign the name in a loop. You can substitute your desired fieldname instead of these.
for i=1:length(Cluster_split)
myValue = Cluster_split{i};
myFieldname = ['thing' num2str(i)];
myStruct.(myFieldname) = myValue;
end
You can now inspect the structure:
myStruct.thing1
myStruct.thing23

추가 답변 (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