MATLAB: How remove a field inside a structure

deletermfield

I need to remove a field which is inside a structure. I did attach the file to help for understanding the issue.
sd does have a field called Variables, and inside Variables filed, there are 6 fields. then inside each of these, there is Attributes and Text. I need to remove Text from all. I tried the following, but the error is saying too many arguments.
fieldsS = fieldnames(sd.Variables);S = rmfield(sd,fieldsS(:),'Text');code
I read this link, but this case is different as there are many fields inside the structure. https://uk.mathworks.com/matlabcentral/answers/29610-how-do-i-delete-a-field-variable-from-a-structure%20

Best Answer

fieldsS = fieldnames(sd.Variables);
for i = 1:length(fieldsS)
S.Variables.(fieldsS{i}) = rmfield(sd.Variables.(fieldsS{i}),'Text');
end
This could help.