Prev: Return digits of a number as a list
Next: the code with the book :A Guide to MATLAB Object-Oriented Programming
From: michael on 30 Apr 2010 01:37 i have 2 types of files, each with different number of fields. i wanna read the whole line in each file and put it in a struct. i want that the process of struct building will be dynamic - i'm reading the fields name and this will be the struct fields [tree, RootName, DOMnode]=xml_read('Hospital.map'); % read whole XML file %% read walls/room dataLength=length(tree.Walls.Room); %number of lines fieldQuantity=length(fieldnames(tree.Walls.Room(1).ATTRIBUTE)); %number of fields FieldNames=fieldnames(tree.Walls.Room(1).ATTRIBUTE); for i=1: fieldQuantity points(dataLength).FieldNames(i)=0; end but withthis code i get struct with only one field - points.FieldNames how to change the code so i'll get the fields listed in FieldNames |