Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Modify multiple field values in a structure
Replies: 2   Last Post: Oct 30, 2013 10:45 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
mo_sahs

Posts: 1
Registered: 10/27/13
Modify multiple field values in a structure
Posted: Oct 27, 2013 5:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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 sub-structures with multiple nested fields for example there is a sub-structure 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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.