How to select a specific line from text file

4 views (last 30 days)
please, I have a text file of Radiosonde data, and I want to select a specific value from the first coulmn of the data.
I tried textscan function, but by using specific number of the header, it removes all the wanted headerlines and still give me all the rest of data.
this is a sample of my data, I want to select the first temperature record (here is -34.9) only from the whole text.
<HTML>
<TITLE>University of Wyoming - Radiosonde Data</TITLE>
<BODY BGCOLOR="white">
<H2>71081 YUX Hall Beach Observations at 12Z 13 Dec 2016</H2>
<PRE>
-----------------------------------------------------------------------------
PRES HGHT TEMP DWPT RELH MIXR DRCT SKNT THTA THTE THTV
hPa m C C % g/kg deg knot K K K
-----------------------------------------------------------------------------
1008.0 6 -31.7 -34.9 73 0.20 300 8 240.9 241.5 240.9
1000.0 61 -28.3 -31.4 75 0.28 310 16 244.8 245.6 244.9
995.0 97 -25.7 -29.5 70 0.34 314 16 247.8 248.8 247.9
967.0 305 -22.6 -29.8 52 0.34 340 16 253.0 253.9 253.0
961.0 350 -21.9 -29.9 48 0.34 336 15 254.1 255.1 254.2
927.6 610 -21.3 -31.2 41 0.31 315 12 257.3 258.2 257.3
925.0 631 -21.3 -31.3 40 0.30 295 11 257.5 258.4 257.6
901.0 825 -21.9 -29.9 48 0.36 312 10 258.9 259.9 258.9
any advice, please.
Thanks

Accepted Answer

Ameer Hamza
Ameer Hamza on 21 Nov 2020
If the file have fixed number of header lines, then try this
f = fopen('data.txt');
data = textscan(f, '%f', 'HeaderLines', 9);
fclose(f);
val = data{1}(3)

More Answers (0)

Categories

Find more on Text Data Preparation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!