Hi Maura,
I understand that you are facing an issue reading the xml file and parsing the data from the 'BeamData' element, and extract the pairs of values 'd_i' and 'v_i'.
Please follow the below code sample to proceed further,
xmlFile = 'yourfile.xml';
xDoc = xmlread(xmlFile);
% Navigate to the BeamData node or node of intrest.
beamDataNode = xDoc.getElementsByTagName('BeamData').item(0);
% Extract the text content of the BeamData node
dataStr = char(beamDataNode.getTextContent());
% Split the string by ';' to separate each pair
dataPairs = strsplit(dataStr, ';');
d_values = [];
v_values = [];
for i = 1:length(dataPairs)
if ~isempty(dataPairs{i})
% Split each pair by ','
values = strsplit(dataPairs{i}, ',');
% Convert strings to numbers and store in vectors
d_values(end+1) = str2double(values{1});
v_values(end+1) = str2double(values{2});
end
end
For a comprehensive understanding of the 'xmlread' and 'strsplit' functions in MATLAB, please refer to the following documentation.
I hope this helps!