Reassign field(Structures)

Risposte (1)

BhaTTa
BhaTTa il 21 Ott 2024

0 voti

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.

Categorie

Richiesto:

il 28 Giu 2017

Commentato:

il 21 Ott 2024

Community Treasure Hunt

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

Start Hunting!

Translated by