13-3 ?用?改變?構陣??欄?

ϥ fieldnames OiǦ^@c}CҦAҦpG

Example 1: 13-c}C/fieldNames01.mstudent = struct('name', 'Roland', 'scores', [80, 90]); allFields = fieldnames(student) allFields = 'name' 'scores'

bWҤAǦ^GO@Ӧr겧}C]Cell Array of Strings^A]tF student ҦC

W[@ӷsAN[J@}CYiAҦpG

Example 2: 13-c}C/addField01.mclear student % M student ܼ student = struct('name', 'Roland', 'scores', [80, 90]); student(2).age = 20; % [Js student(1) % student(1) student(2) % student(2) ans = name: 'Roland' scores: [80 90] age: [] ans = name: [] scores: [] age: 20

ѤWzGiݥXAMATLAB |Ns[JLAó]ww]Ȭ []]ůx}^C

R@Ai rmfield OAϥή榡pUG

newArray = rmfield(array, 'field')

ҦpAR scores AiJpUG

Example 3: 13-c}C/rmField01.mstudent = struct('name', 'Roland', 'scores', [80, 90]) student2 = rmfield(student, 'scores') % R scores student = name: 'Roland' scores: [80 90] student2 = name: 'Roland'


MATLAB{]pGJg