Function rmfield - structure:
The function rmfield eliminates a field from the structure. It returns a new structure with field eliminated, but does not modify the original structure (except the returned structure is assigned to that variable). For illustration, the below would eliminate the code field from the newpack structure, however store the resulting structure in the default variable ans. The value of the newpack remains unaffected.
>> rmfield(newpack, 'code')
ans =
item_no: 111
cost: 19.9900
price: 34.9500
>> newpack
newpack =
item_no: 111
cost: 19.9000
price: 34.9500
code: 'g'
To change the value of newpack, the structure which results from calling rmfield should be assigned to newpack.
>> newpack = rmfield(newpack, 'code')
newpack =
item_no: 111
cost: 19.9000
price: 34.9500