need help parsing data from .dat file
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I can not seem to parse out the data in matlab. here is an example.
0R1,Dn=099D,Dm=099D,Dx=099D,Sn=1.9M,Sm=1.9M,Sx=2.0M 0R1,Dn=111D,Dm=111D,Dx=111D,Sn=2.8M,Sm=2.8M,Sx=2.9M 0R1,Dn=103D,Dm=103D,Dx=103D,Sn=3.0M,Sm=3.1M,Sx=3.1M 0R1,Dn=113D,Dm=113D,Dx=113D,Sn=3.1M,Sm=3.1M,Sx=3.2M 0R1,Dn=088D,Dm=088D,Dx=088D,Sn=2.5M,Sm=2.5M,Sx=2.6M 0R1,Dn=104D,Dm=104D,Dx=104D,Sn=2.7M,Sm=2.8M,Sx=2.8M 0R1,Dn=122D,Dm=122D,Dx=122D,Sn=2.8M,Sm=2.9M,Sx=2.9M 0R1,Dn=109D,Dm=109D,Dx=109D,Sn=2.8M,Sm=2.8M,Sx=2.9M 0R1,Dn=121D,Dm=121D,Dx=121D,Sn=2.5M,Sm=2.6M,Sx=2.6M 0R1,Dn=134D,Dm=134D,Dx=134D,Sn=2.3M,Sm=2.3M,Sx=2.4M 0R1,Dn=147D,Dm=147D,Dx=147D,Sn=2.0M,Sm=2.1M,Sx=2.1M 0R1,Dn=129D,Dm=129D,Dx=129D,Sn=1.6M,Sm=1.6M,Sx=1.7M 0R1,Dn=136D,Dm=136D,Dx=136D,Sn=1.3M,Sm=1.3M,Sx=1.4M
i just need the numbers; however when i try to use the built in importer it does not even separate the data with commas.
please help.
here is what the beginning of the file looks like.
$GPGGA,044238,3252.1847,N,11715.0445,W,1,03,8.3,,M,-33.0,M,,*58 $GPRMC,044239,A,3252.1841,N,11715.0441,W,000.0,000.0,060309,013.0,E*6A $GPGGA,044239,3252.1841,N,11715.0441,W,1,03,8.3,,M,-33.0,M,,*5B $GPRMC,044240,A,3252.1810,N,11715.0438,W,000.0,000.0,060309,013.0,E*6E $GPGGA,044240,3252.1810,N,11715.0438,W,1,03,8.3,,M,-33.0,M,,*5F $GPRMC,044241,A,3252.1790,N,11715.0436,W,000.0,000.0,060309,013.0,E*66 $GPGGA,044241,3252.1790,N,11715.0436,W,1,03,8.3,,M,-33.0,M,,*57 $GPRMC,044242,A,3252.1775,N,11715.0432,W,000.0,000.0,060309,013.0,E*6A $GPGGA,044242,3252.1775,N,11715.0432,W,1,05,8.3,,M,-33.0,M,,*5D $GPRMC,044243,A,3252.1785,N,11715.0434,W,000.4,000.0,060309,013.0,E*66 $GPGGA,044243,3252.1785,N,11715.0434,W,1,05,2.4,,M,-33.0,M,,*58 $GPRMC,go
$:E010*6A $C0.00T12.4:E200*79 $C-1.00T11.7:E200*55 $C-1.00T11.3:E200*51 $C-1.00T12.4:E200*55 $C-1.00T11.9:E200*5B $C-1.00T11.7:E200*55 $C-1.00T12.0:E200*51 $C-1.00T12.0:E200*51 $C-1.00T12.4:E200*55 $C-1.00T12.0:E200*51 0R1,Dn=099D,Dm=099D,Dx=099D,Sn=1.9M,Sm=1.9M,Sx=2.0M 0R1,Dn=111D,Dm=111D,Dx=111D,Sn=2.8M,Sm=2.8M,Sx=2.9M
in addition to parsing i would like to know how to automate it for many files of the same type.
any help would be much appreciated. thank you.
0 commentaires
Réponses (2)
Jan
le 6 Juil 2011
Please explain, if the $-lines are comment lines, which should be ignored.
Your statement "i just need the numbers;" is not clear. Which numbers do you want for this line:
0R1,Dn=111D,Dm=111D,Dx=111D,Sn=2.8M,Sm=2.8M,Sx=2.9M
Perhaps these:
0 1 111 111 111 2.8 2.8 2.9
?
0 commentaires
Ashish Uthama
le 8 Juil 2011
Please do update the question clarifying Jan's comments.
>> s = '0R1,Dn=136D,Dm=136D,Dx=136D,Sn=1.3M,Sm=1.3M,Sx=1.4M'
>> numStrings = regexp(s,'=[0-9.]+','match')
numStrings =
'=136' '=136' '=136' '=1.3' '=1.3' '=1.4'
>> numStrings = strrep(numStrings,'=','')
numStrings =
'136' '136' '136' '1.3' '1.3' '1.4'
>> nums = str2double(numStrings)
nums =
136.0000 136.0000 136.0000 1.3000 1.3000 1.4000
0 commentaires
Voir également
Catégories
En savoir plus sur String Parsing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!