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 月 30 日
Could you post a sample file for us to test with?
andrea vironda
andrea vironda 2020 年 7 月 30 日
Here the zip file
Basically the first part is useless to me, it is simply the setup environment.
t is in [s], f1 in [A], f2 in [°/min], f3 in [°]. It's an electrical test and i wish to plot the data
Walter Roberson
Walter Roberson 2020 年 7 月 30 日
There are thousands of broken records in the file. For example,
<rec time="5.842000" f1="-0.229889" f2="0.000671" f3="359.989757"/>
<rec time="5.844000" f1="-0.232361" f3="359.989765"/>
<rec time="5.846000" f2="-0.001341" f3="359.989749"/>
<rec time="5.848000" f2="0.000447" f3="359.989754"/>
<rec time="5.850000" f2="0.000000"/>
Notice the second line is missing f2, the third and fourth are missing f1, the fifth is missing f1 and f3.
What would you like to have happen in those cases? There are even some records that are missing time information.
andrea vironda
andrea vironda 2020 年 7 月 31 日
編集済み: andrea vironda 2020 年 7 月 31 日
In those cases, i can accept an average between i-1 and i+1
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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by