Reassign field(Structures)

1 回表示 (過去 30 日間)
Yunming Zhang
Yunming Zhang 2017 年 6 月 28 日
コメント済み: Stephen23 2024 年 10 月 21 日
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 件)

BhaTTa
BhaTTa 2024 年 10 月 21 日
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.

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by