Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


mo_sahs
Posts:
1
Registered:
10/27/13


Modify multiple field values in a structure
Posted:
Oct 27, 2013 5:19 PM


This may be a basic question as I'm relatively new to matlab. I have a DICOM file which I've read the headers for into a structure using the dicominfo function. I would like to modify certain fields where there is more than one instance so for example:
info=dicominfo('Some dicim file.dcm');
Within info, there multiple substructures with multiple nested fields for example there is a substructure called SOPInstanceUID, and within this there are n fields storing value: field_1, field_2..field_n
To see the a certain value I can type within the structure:
value=info.SOPInstanceUID.field_1;
However I would like to set a new value i.e to then write a new DICOM file.
info.SOPInstanceUID.field_1=newvalue;
I would like to do this automatically for all possible field numbers e.g:
num_fields=fieldnames(info.SOPInstanceUID);
for i=1:length(num_fields)
info.SOPInstanceUID.field_i=newvalue_i;
end
My question is how do I get Matlab to read the field name for each 'i', in order to set a new value for each field in the structure? I have tried various things like str2cat and sprintf but nothing works.
I hope this make sense and I would be very grateful for any help on this.
Thanks



