Hello
I try understanding regexp function. I want you to guide me for next step. Because I got stuck.
I would like to read specific parts of a file as pattern and then write it to text file?
Data section is between START OF TEC MAP and END OF TEC MAP.
%Read contents of a file as text, specified as a character vector or string scalar
str = fileread ('codg1520.14i');% Data section
matchStr = regexp( str, '(?<=START OF TEC MAP).+?(?=END OF TEC MAP)', 'match' );
Array of the size 71x73x12 or 71x73x24 or 71x73x25 as latitude, longitude, universal time. It depends on file. Array of the size 71x73x12 for this file.
I am not sure that if necessary I can delete strings of each line or extract numbers of each line into cell arrays.
% extract numbers of each line
C = regexp(matchStr, '\d*\.?\d*', 'match');
How to extract data 2nd row the last five longitude values?
For example:
2014 6 1 0 0 0 EPOCH OF CURRENT MAP 45.0-180.0 180.0 5.0 450.0 LAT/LON1/LON2/DLON/H 278 289 295 297 293 286 275 260 244 229 217 208 201 195 188 180 174 170 169 170 170 171 170 170 171 172 172 170 164 154 143 131 122 116 114 117 121 125 126 124 122 123 127 134 141 148 154 161 171 187 206 226 244 255 258 254 246 236 228 221 214 208 202 198 198 201 208 216 225 236 249 264 278
Lat = 45
Data = 170 164 154 143 131
Whatever I tried, I always get error message. So what should I do next move to parse data and then write it to text file?
Best Answer