Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
reading files with fields

Subject: reading files with fields

From: MICHAEL

Date: 30 Apr, 2010 05:37:04

Message: 1 of 1

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

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us