Reading blocks of data

3 views (last 30 days)
Sebastian Ciuban
Sebastian Ciuban on 24 May 2014
Answered: dpb on 25 May 2014
13 03 12 00 00 0.0000000 0 7 G05 G16 G21 G25 G29 G30 G31*
23178802.640 121805444.22508 -722.816 23178801.180 94913344.40346
-563.238
23899154.020 125590912.38807 3334.078 23899151.480 97863037.80844
2597.980
I have this ASCII format file with data shown above. I want to extract, with a function, from this block the following: The satellite number and its coresponding data.
First satellite (G05) corresponds to 1'st and 2'nd line of data and so on for the rest of the satellites(G16, G21, G25 etc.)
As output of function, I'm looking forward to obtain a 7 x n matrix, where n=number of satellites:
e.g: Observation (7xn) =[ 5 16 n
23178802.640 23899154.020 ---
121805444.22508 125590912.38807 ---
-722.816 3334.078 ---
23178801.180 23899151.480 ---
94913344.40346 97863037.80844 ---
-563.238 2597.980 ---]
Any advices or ideas on how I should start would be very much appreciated.
Note: The data blocks are from an RINEX OBSERVATION file.

Accepted Answer

dpb
dpb on 25 May 2014
13 03 12 00 00 0.0000000 0 7 G05 G16 G21 G25 G29 G30 G31*
fid=fopen('filename.txt','r'); % open file
l=fgetl(fid); % get header line to parse
[n,~,~,nxt]=sscanf(l,[repmat('%*f',1,7) '%d']); % find n, number of sat's, next place in string
fmt=[repmat('G%d ',1,n-1) 'G%d*']; % build format string for the sat's
s=sscanf(l(nxt:end),fmt); % read sat no's
d=cell2mat(textscan(fid),repmat('%f',1,6))).'; % read and reshape data

More Answers (0)

Community Treasure Hunt

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

Start Hunting!