How to deal with a nestled struct

조회 수: 1 (최근 30일)
andrea vironda
andrea vironda 2020년 7월 30일
답변: Walter Roberson 2020년 7월 31일
Hi,
I have a xlm I wish to study. I used this code:
clc; clear all; close all
sampleXMLfile = 'A_AXIS_1.xml';
xDoc=parseXML(sampleXMLfile);
I need to manage data starting from line 87:
Browsing the struct i can find the data here
xDoc(2).Children(10).Children(2).Children(12).Attributes
Here i can find rec time, f1, f2 and f3 as Attributes.
How can i transfer them in a matrix so i can manipulate them?
  댓글 수: 6
Walter Roberson
Walter Roberson 2020년 7월 31일
In the subset I show, there are three records in a row with no f1, so taking mean of two adjacent records would not be able to fill the gap.
There are places that have over 75 missing f1 in a row.
When a defective record is encountered, can the entire record be discarded, and everything calculated based on only the full records? Or should as much be recovered as possible (a slower more complicated process)?
andrea vironda
andrea vironda 2020년 7월 31일
I think discard the record is the best solution. In a second step i can think how to deal with missing parameters

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2020년 7월 31일
sampleXMLfile = 'A_AXIS_1.xml';
S = fileread(sampleXMLfile);
just_numeric_cell = regexp(S, 'time="-?([\d.]+)" f1="-?([\d.]+)" f2="-?([\d.]+)" f3="-?([\d.]+)"', 'tokens');
just_numeric_array = vertcat(just_numeric_cell{:});
Attributes = str2double(just_numeric_array);
This finds about 6700 full records, with there being roughly another 2200 partial records in the file.
The largest time gap is about 0.07 seconds.
The order of columns is time, f1, f2, f3.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by