Reassign field(Structures)
이전 댓글 표시
Let's say I have a 1 X N cell array s1 which is sorted from structure.fieldname, how can I reassign s1 to structure.fieldname? I
댓글 수: 1
Stephen23
2024년 10월 21일
[structure.fieldname] = s1{:}
답변 (1개)
BhaTTa
2024년 10월 21일
0 개 추천
Hey @Yunming Zhang, Suppose you have a structure named myStruct and a field within it called fieldname. If s1 is the sorted cell array you want to assign back to myStruct.fieldname, you can do it directly by . indexing:
% Assume myStruct is your structure and s1 is the sorted 1xN cell array
myStruct.fieldname = s1;
% Now, myStruct.fieldname contains the sorted values from s1
Hope it helps.
카테고리
도움말 센터 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!