Reassign field(Structures)

27 Ansichten (letzte 30 Tage)
Yunming Zhang
Yunming Zhang am 28 Jun. 2017
Kommentiert: Stephen23 am 21 Okt. 2024
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

Antworten (1)

BhaTTa
BhaTTa am 21 Okt. 2024
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.

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by