Borrar filtros
Borrar filtros

How to grab specific value in txt data?

2 visualizaciones (últimos 30 días)
adhi dermawan
adhi dermawan el 31 de En. de 2023
Comentada: Mathieu NOE el 1 de Feb. de 2023
Greeting matlab expert, I have a meteorologi data and the content just like below
96935 WRSJ Surabaya Observations at 00Z (Time) 01 Jan 2022 (Date)
-------------------------------------------------------------------------------------------
PRES HGHT TEMP DWPT FRPT RELH RELI MIXR DRCT SKNT THTA THTE THTV
hPa m C C C % % g/kg deg knot K K K
-------------------------------------------------------------------------------------------
1009.0 3 24.4 22.9 22.9 91 91 17.78 0 0 296.8 348.3 299.9
1000.0 86 24.4 23.1 23.1 92 93 18.17 295 8 297.6 350.4 300.8
976.0 299 24.8 21.1 21.1 80 80 16.39 285 6 300.0 348.1 302.9
973.0 326 24.8 20.8 20.8 78 79 16.17 282 6 300.3 347.9 303.2
943.0 600 23.8 19.2 19.2 75 75 15.08 255 8 302.0 346.7 304.7
925.0 768 23.2 18.2 18.2 73 74 14.43 250 11 303.0 346.0 305.6
889.0 1114 21.2 15.2 15.2 69 69 12.37 258 14 304.4 341.5 306.7
880.0 1202 20.5 15.2 15.2 72 72 12.48 260 15 304.6 342.0 306.8
850.0 1501 18.0 15.1 15.1 83 83 12.86 265 14 305.0 343.6 307.3
751.0 2552 11.6 10.0 10.0 90 90 10.37 274 12 309.0 340.9 310.9
741.0 2665 12.4 6.4 6.4 67 67 8.20 275 12 311.1 336.7 312.6
738.0 2699 12.2 6.3 6.3 67 67 8.19 275 12 311.2 336.8 312.8
700.0 3141 9.6 5.3 5.3 75 75 8.04 265 12 313.1 338.4 314.6
673.0 3467 7.8 4.5 4.5 80 80 7.91 258 13 314.6 339.6 316.1
662.0 3603 8.3 -3.8 -3.4 42 42 4.37 255 13 316.7 331.0 317.6
661.0 3615 8.4 -4.6 -4.1 39 40 4.13 255 13 316.9 330.5 317.7
656.0 3678 7.6 -0.4 -0.3 57 57 5.70 255 13 316.7 335.1 317.8
645.0 3817 6.8 -2.2 -1.9 53 53 5.07 256 14 317.3 333.9 318.3
639.0 3894 6.2 1.4 1.4 71 71 6.67 256 15 317.5 339.0 318.8
572.0 4792 0.0 -3.3 -2.9 78 79 5.27 260 19 320.4 337.8 321.4
569.0 4834 0.4 -5.6 -5.0 64 64 4.45 260 19 321.4 336.2 322.2
508.0 5735 -4.7 -8.4 -7.5 75 79 4.02 264 24 325.8 339.4 326.6
500.0 5860 -5.5 -10.2 -9.1 69 73 3.54 265 25 326.3 338.4 327.0
488.0 6051 -5.9 -12.9 -11.5 58 61 2.92 269 25 328.1 338.2 328.6
474.0 6278 -7.9 -10.8 -9.6 80 86 3.56 275 26 328.3 340.6 329.0
473.0 6294 -8.0 -11.0 -9.8 79 85 3.51 275 26 328.4 340.6 329.1
429.0 7048 -12.1 -20.1 -18.0 51 58 1.82 292 25 332.5 339.1 332.8
417.0 7264 -13.7 -18.6 -16.6 67 76 2.13 298 25 333.1 340.8 333.5
400.0 7580 -15.5 -20.5 -18.4 66 76 1.88 305 25 334.8 341.6 335.1
395.0 7675 -15.5 -18.3 -16.4 79 92 2.30 305 25 336.0 344.3 336.4
391.0 7753 -15.9 -22.9 -20.6 55 64 1.56 305 24 336.4 342.2 336.7
388.0 7811 -16.1 -22.1 -19.9 60 70 1.69 305 24 336.9 343.1 337.2
385.0 7870 -16.3 -23.3 -20.9 55 64 1.53 305 24 337.4 343.1 337.7
375.0 8069 -16.7 -27.7 -25.0 38 45 1.05 305 23 339.4 343.4 339.6
340.0 8799 -22.7 -36.7 -33.4 27 33 0.49 305 20 340.9 342.8 341.0
331.0 8996 -24.1 -35.4 -32.2 34 43 0.57 305 19 341.6 343.9 341.7
323.0 9176 -25.3 -34.3 -31.1 43 55 0.65 305 20 342.3 344.9 342.4
300.0 9710 -29.3 -38.3 -34.9 41 55 0.47 305 21 344.0 345.9 344.1
291.0 9926 -31.1 -39.1 -35.7 45 61 0.45 308 20 344.4 346.2 344.5
268.0 10498 -36.0 -41.8 -38.2 55 79 0.37 315 19 345.5 347.0 345.6
250.0 10980 -40.1 -44.0 -40.3 66 98 0.31 335 13 346.3 347.6 346.4
246.0 11090 -41.0 -44.6 -40.9 68 102 0.30 340 12 346.6 347.8 346.7
229.0 11576 -44.9 -47.1 -43.3 78 121 0.24 328 10 347.8 348.8 347.8
225.0 11692 -45.9 -49.0 -45.0 71 111 0.20 325 9 347.9 348.8 348.0
215.0 11993 -48.6 -53.7 -49.7 55 88 0.12 345 11 348.3 348.9 348.4
202.0 12405 -52.3 -60.3 -56.1 37 62 0.06 345 14 348.8 349.1 348.8
200.0 12470 -52.9 -60.9 -56.7 37 62 0.05 345 15 348.8 349.1 348.9
187.0 12896 -56.9 -63.6 -59.3 42 72 0.04 0 15 349.2 349.4 349.2
180.0 13138 -59.1 -65.1 -60.8 46 79 0.03 0 15 349.4 349.5 349.4
178.0 13206 -59.7 -65.8 -61.5 45 78 0.03 0 15 349.5 349.6 349.5
150.0 14250 -69.3 -77.3 -73.0 30 57 0.01 35 18 350.5 350.6 350.5
132.0 14983 -75.7 -86.2 -82.1 18 35 0.00 40 27 352.2 352.2 352.2
119.0 15578 -80.8 -93.5 -89.7 11 21 0.00 50 37 353.3 353.3 353.3
111.0 15978 -84.3 -98.3 -94.7 7 15 0.00 55 55 353.9 353.9 353.9
107.0 16182 -82.8 -96.5 -92.8 8 17 0.00 55 57 360.4 360.4 360.4
100.0 16560 -80.1 -93.1 -89.3 10 20 0.00 55 34 372.7 372.7 372.7
96.0 16789 -81.2 -95.0 -91.2 9 17 0.00 50 19 374.8 374.8 374.8
91.0 17089 -82.8 -97.4 -93.8 7 13 0.00 125 5 377.6 377.6 377.6
89.3 17195 -83.3 -98.3 -94.7 6 12 0.00 147 6 378.6 378.6 378.6
86.0 17405 -83.0 -98.0 -94.5 6 12 0.00 190 7 383.2 383.2 383.2
84.2 17523 -82.9 -97.9 -94.3 6 13 0.00 257 7 385.8 385.8 385.8
82.0 17673 -80.9 -96.2 -92.5 6 13 0.00 340 6 392.8 392.8 392.8
77.0 18031 -76.3 -92.2 -88.3 7 13 0.00 330 10 409.6 409.6 409.6
76.4 18075 -75.7 -91.7 -87.8 7 13 0.00 325 11 411.7 411.7 411.7
70.0 18580 -77.1 -95.1 -91.4 4 8 0.00 265 17 419.1 419.1 419.1
67.3 18805 -77.9 -95.9 -92.2 4 8 0.00 224 12 422.1 422.1 422.1
63.0 19188 -74.3 -95.0 -91.2 3 6 0.00 155 4 438.2 438.2 438.2
61.0 19375 -72.5 -94.5 -90.8 2 5 0.00 147 14 446.2 446.2 446.2
57.0 19775 -72.0 -98.0 -94.5 1 2 0.00 130 36 456.1 456.1 456.1
52.5 20260 -71.3 -102.3 -99.0 0 1 0.00 111 36 468.5 468.5 468.5
50.0 20550 -69.1 -100.1 -96.6 0 1 0.00 100 36 480.2 480.2 480.2
44.0 21325 -64.5 -97.0 -93.4 0 1 0.00 80 37 509.3 509.3 509.3
42.3 21564 -63.1 -96.1 -92.4 0 1 0.00 83 42 518.6 518.6 518.6
38.0 22229 -60.3 -94.2 -90.5 0 1 0.00 90 55 541.8 541.8 541.8
37.7 22278 -60.1 -94.1 -90.3 0 1 0.00 90 55 543.5 543.6 543.5
31.9 23317 -61.5 -94.5 -90.8 1 1 0.00 94 59 566.4 566.4 566.4
30.0 23700 -59.3 -93.3 -89.5 1 1 0.00 95 60 582.4 582.4 582.4
27.4 24272 -55.9 -90.9 -87.0 1 1 0.00 92 62 607.2 607.2 607.2
21.0 25968 -54.8 -89.8 -85.8 1 1 0.01 85 66 658.5 658.5 658.5
20.5 26122 -54.7 -89.7 -85.8 1 1 0.01 85 67 663.3 663.4 663.3
20.0 26280 -54.3 -89.3 -85.3 1 1 0.01 85 68 669.2 669.3 669.2
19.0 26611 -53.0 -92.2 -88.4 0 0 0.00 90 71 683.0 683.0 683.0
18.7 26713 -52.6 -93.2 -89.3 0 0 0.00 90 71 687.3 687.4 687.3
18.0 26960 -51.7 -95.3 -91.6 0 0 0.00 90 70 697.8 697.9 697.8
17.9 26996 -51.6 -95.7 -92.0 0 0 0.00 90 70 699.4 699.4 699.4
17.7 27068 -51.3 -96.3 -92.6 0 0 0.00 702.5 702.5 702.5
Station information and sounding indices
Station identifier: WRSJ
Station number: 96935
Observation time: 220101/0000
Station latitude: -7.36
Station longitude: 112.76
Station elevation: 3.0
Showalter index: -0.07
Lifted index: -1.89
LIFT computed using virtual temperature: -2.28
SWEAT index: 234.21
K index: 34.30
Cross totals index: 20.60
Vertical totals index: 23.50
Totals totals index: 44.10
Convective Available Potential Energy: 262.99
CAPE using virtual temperature: 365.23
Convective Inhibition: -78.51
CINS using virtual temperature: -61.08
Equilibrum Level: 244.09
Equilibrum Level using virtual temperature: 243.43
Level of Free Convection: 809.39
LFCT using virtual temperature: 827.18
Bulk Richardson Number: 28.44
Bulk Richardson Number using CAPV: 39.50
Temp [K] of the Lifted Condensation Level: 293.97
Pres [hPa] of the Lifted Condensation Level: 939.12
Equivalent potential temp [K] of the LCL: 348.46
Mean mixed layer potential temperature: 299.31
Mean mixed layer mixing ratio: 16.82
1000 hPa to 500 hPa thickness: 5774.00
Precipitable water [mm] for entire sounding: 55.09 (PW Value)
The data above is only one part of the text. This data is during January with a span of every 12 hours. I also attached the complete text. Is it possible to pick every (Time) (Date) in the first line and (PW Value) in the last line from the data and make a new list of (Time) (Date) (PW Value) only?

Respuesta aceptada

Mathieu NOE
Mathieu NOE el 31 de En. de 2023
hello
try this :
D=readlines('2022_01.txt'); % read as string array
% find the time and date lines
ixP1=find(contains(D,'Observations at '));
tmp = extractAfter(D(ixP1),'Observations at ');
tmp = split(tmp,' ');
time = tmp(:,1);
date = tmp(:,2:end);
% find the PW lines
ixP2=find(contains(D,'Precipitable water [mm]'));
tmp = split(D(ixP2),':');
PW = tmp(:,end);
% output = string concatenation
for ci=1:numel(ixP1) % process each section in turn
out(ci,:) = [time(ci) date(ci,:) "PW = " PW(ci)];
end
% save to txt file
writematrix(out,'out.txt',"delimiter","tab");
  4 comentarios
adhi dermawan
adhi dermawan el 1 de Feb. de 2023
thank you so much for helping me with the complete code sir.
Mathieu NOE
Mathieu NOE el 1 de Feb. de 2023
as always, my pleasure !

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by