using fget1 to read text file. Need help sorting data
显示 更早的评论
Using the fgetl function I'm making a program to read this text file line by line. I need to be able to seperate the data entries from each other and store them in their own designated variables. You will see in the text file that some of the data entries start with a G (GPS) and other ones start with an R (GLONASS). I need to be able to get the program to recogize that first character that signifies GPS or GLONASS and then proceed to store the data entries in between. The number of data entries and lines of data are constant for both constellations. GPS has 8 lines and 34 data entries. GLONASS has 4 lines and 22 entries.
G32 2020 01 03 22 00 00 1.747743226588E-04 1.091393642128E-11 0.000000000000E+00
3.500000000000E+01-1.318750000000E+01 4.651979487904E-09 5.385931295143E-01
-7.767230272293E-07 3.395725856535E-03 9.786337614059E-06 5.153669069290E+03
5.112000000000E+05 1.862645149231E-09 1.499495835472E+00 3.725290298462E-08
9.563698279564E-01 1.892187500000E+02-2.550865203809E+00-8.079265105250E-09
-1.246480492344E-10 1.000000000000E+00 2.086000000000E+03 0.000000000000E+00
2.000000000000E+00 0.000000000000E+00 4.656612873077E-10 3.500000000000E+01
5.040180000000E+05 4.000000000000E+00
R01 2020 01 03 00 15 00 5.505327135324E-05 0.000000000000E+00 4.320000000000E+05
-1.407114599609E+04 6.327390670776E-01-0.000000000000E+00 0.000000000000E+00
-1.985983984375E+04 8.451271057129E-01-1.862645149231E-09 1.000000000000E+00
-7.659376464844E+03-3.354722023010E+00 0.000000000000E+00 0.000000000000E+00
R01 2020 01 03 00 45 00 5.505420267582E-05 0.000000000000E+00 4.338000000000E+05
-1.228681494141E+04 1.356384277344E+00-9.313225746155E-10 0.000000000000E+00
-1.796078857422E+04 1.222489356995E+00-1.862645149231E-09 1.000000000000E+00
-1.332407470703E+04-2.898560523987E+00 9.313225746155E-10 0.000000000000E+00
R01 2020 01 03 01 15 00 5.505513399839E-05 0.000000000000E+00 4.356000000000E+05
-9.198476562500E+03 2.062785148621E+00-9.313225746155E-10 0.000000000000E+00
-1.561752148438E+04 1.336973190308E+00-9.313225746155E-10 1.000000000000E+00
-1.795952929688E+04-2.218539237976E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 01 45 00 5.505699664354E-05 0.000000000000E+00 4.374000000000E+05
-4.937781250000E+03 2.641427993774E+00-9.313225746155E-10 0.000000000000E+00
-1.329891015625E+04 1.200849533081E+00-0.000000000000E+00 1.000000000000E+00
-2.120773779297E+04-1.367164611816E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 02 15 00 5.505792796612E-05 0.000000000000E+00 4.392000000000E+05
1.769560546875E+02 2.998314857483E+00-9.313225746155E-10 0.000000000000E+00
-1.141282763672E+04 8.685550689697E-01-0.000000000000E+00 1.000000000000E+00
-2.281775537109E+04-4.101181030273E-01 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 02 45 00 5.505885928869E-05 0.000000000000E+00 4.410000000000E+05
5.685046386719E+03 3.071467399597E+00-9.313225746155E-10 0.000000000000E+00
-1.023803710938E+04 4.269771575928E-01 0.000000000000E+00 1.000000000000E+00
-2.266500244141E+04 5.787792205811E-01 2.793967723846E-09 0.000000000000E+00
R01 2020 01 03 03 15 00 5.505979061127E-05 0.000000000000E+00 4.433700000000E+05
1.105128369141E+04 2.841253280640E+00-0.000000000000E+00 0.000000000000E+00
-9.878704101562E+03-1.961040496826E-02 9.313225746155E-10 1.000000000000E+00
-2.076089892578E+04 1.523207664490E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 03 45 00 5.506072193384E-05 0.000000000000E+00 4.446000000000E+05
1.574637890625E+04 2.333828926086E+00 0.000000000000E+00 0.000000000000E+00
-1.024903222656E+04-3.674869537354E-01 9.313225746155E-10 1.000000000000E+00
-1.725210107422E+04 2.350193023682E+00 1.862645149231E-09 0.000000000000E+00
14 个评论
Rik
2020-7-11
What have you tried so far? Sound like it should be possible with a loop and an if.
Image Analyst
2020-7-11
Isn't this a duplicate question to this one?
Engineer_guy
2020-7-11
Engineer_guy
2020-7-11
Engineer_guy
2020-7-11
Star Strider
2020-7-11
It would be best to have at least a representative sample of that original file uploaded here in the original format (likely as a .txt file) or possibly as a .mat file. We really don’t know what we’re working with, otherwise.
Engineer_guy
2020-7-11
dpb
2020-7-11
You can certainly save a few hundred lines and attach that...
I've no klew what RINEX file is; looks like first entry is a date/time, maybe? What's its format?
I presume there's probably a header that defines the file structure? If so, reading it would undoubtedly make the parsing go much simpler.
Image Analyst
2020-7-11
It's a text file. Therefore you can open it with a text editor, go down a few hundred line, and then delete everything after that. Then save it as a new, now shorter, file. Then attach it here. Why can't you do that? Make it easy for us to help youi, not hard.
Engineer_guy
2020-7-11
Engineer_guy
2020-7-11
Engineer_guy
2020-7-11
Star Strider
2020-7-11
According to Walter Roberson’s Answer, a reader compatible with MATLAB already exists for RINEX .RNX files.
No reason for us to re-invent it if it works with your file.
Steven Lord
2020-10-20
编辑:Steven Lord
2020-10-20
Copying question in case user edits it away.
"Using the fgetl function I'm making a program to read this text file line by line. I need to be able to seperate the data entries from each other and store them in their own designated variables. You will see in the text file that some of the data entries start with a G (GPS) and other ones start with an R (GLONASS). I need to be able to get the program to recogize that first character that signifies GPS or GLONASS and then proceed to store the data entries in between. The number of data entries and lines of data are constant for both constellations. GPS has 8 lines and 34 data entries. GLONASS has 4 lines and 22 entries.
G32 2020 01 03 22 00 00 1.747743226588E-04 1.091393642128E-11 0.000000000000E+00
3.500000000000E+01-1.318750000000E+01 4.651979487904E-09 5.385931295143E-01
-7.767230272293E-07 3.395725856535E-03 9.786337614059E-06 5.153669069290E+03
5.112000000000E+05 1.862645149231E-09 1.499495835472E+00 3.725290298462E-08
9.563698279564E-01 1.892187500000E+02-2.550865203809E+00-8.079265105250E-09
-1.246480492344E-10 1.000000000000E+00 2.086000000000E+03 0.000000000000E+00
2.000000000000E+00 0.000000000000E+00 4.656612873077E-10 3.500000000000E+01
5.040180000000E+05 4.000000000000E+00
R01 2020 01 03 00 15 00 5.505327135324E-05 0.000000000000E+00 4.320000000000E+05
-1.407114599609E+04 6.327390670776E-01-0.000000000000E+00 0.000000000000E+00
-1.985983984375E+04 8.451271057129E-01-1.862645149231E-09 1.000000000000E+00
-7.659376464844E+03-3.354722023010E+00 0.000000000000E+00 0.000000000000E+00
R01 2020 01 03 00 45 00 5.505420267582E-05 0.000000000000E+00 4.338000000000E+05
-1.228681494141E+04 1.356384277344E+00-9.313225746155E-10 0.000000000000E+00
-1.796078857422E+04 1.222489356995E+00-1.862645149231E-09 1.000000000000E+00
-1.332407470703E+04-2.898560523987E+00 9.313225746155E-10 0.000000000000E+00
R01 2020 01 03 01 15 00 5.505513399839E-05 0.000000000000E+00 4.356000000000E+05
-9.198476562500E+03 2.062785148621E+00-9.313225746155E-10 0.000000000000E+00
-1.561752148438E+04 1.336973190308E+00-9.313225746155E-10 1.000000000000E+00
-1.795952929688E+04-2.218539237976E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 01 45 00 5.505699664354E-05 0.000000000000E+00 4.374000000000E+05
-4.937781250000E+03 2.641427993774E+00-9.313225746155E-10 0.000000000000E+00
-1.329891015625E+04 1.200849533081E+00-0.000000000000E+00 1.000000000000E+00
-2.120773779297E+04-1.367164611816E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 02 15 00 5.505792796612E-05 0.000000000000E+00 4.392000000000E+05
1.769560546875E+02 2.998314857483E+00-9.313225746155E-10 0.000000000000E+00
-1.141282763672E+04 8.685550689697E-01-0.000000000000E+00 1.000000000000E+00
-2.281775537109E+04-4.101181030273E-01 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 02 45 00 5.505885928869E-05 0.000000000000E+00 4.410000000000E+05
5.685046386719E+03 3.071467399597E+00-9.313225746155E-10 0.000000000000E+00
-1.023803710938E+04 4.269771575928E-01 0.000000000000E+00 1.000000000000E+00
-2.266500244141E+04 5.787792205811E-01 2.793967723846E-09 0.000000000000E+00
R01 2020 01 03 03 15 00 5.505979061127E-05 0.000000000000E+00 4.433700000000E+05
1.105128369141E+04 2.841253280640E+00-0.000000000000E+00 0.000000000000E+00
-9.878704101562E+03-1.961040496826E-02 9.313225746155E-10 1.000000000000E+00
-2.076089892578E+04 1.523207664490E+00 1.862645149231E-09 0.000000000000E+00
R01 2020 01 03 03 45 00 5.506072193384E-05 0.000000000000E+00 4.446000000000E+05
1.574637890625E+04 2.333828926086E+00 0.000000000000E+00 0.000000000000E+00
-1.024903222656E+04-3.674869537354E-01 9.313225746155E-10 1.000000000000E+00
-1.725210107422E+04 2.350193023682E+00 1.862645149231E-09 0.000000000000E+00
"
采纳的回答
更多回答(1 个)
Walter Roberson
2020-7-11
编辑:Walter Roberson
2020-7-12
0 个投票
类别
在 帮助中心 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!