Extract all indexes inside a text file

3 views (last 30 days)
Munir Baldomero
Munir Baldomero on 3 Jun 2022
Commented: Jon on 3 Jun 2022
How can I extract all the indexes from the following text file? It works for 01June2020 but not for 04June2020.
fid = fopen('01JUNE2020_0000Z.TXT');
cnt=0;
while ~feof(fid)
aa = fgetl(fid);
if length(aa) >= 68
aa = [aa,''];
if strcmp(aa(1:67),' 1 CAPE Total ')
Cape_Total(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 K Index ')
K_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 LI - Lifted Index ')
Lifted_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 SI - Showalter Index ')
Showalter_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 SWEAT Index ')
SWEAT_Index(cnt,1) = str2num(aa(67:length(aa)));
end
if strcmp(aa(1:67),' 1 TT - Total Totals ')
Total_Totals(cnt,1) = str2num(aa(67:length(aa)));
end
cnt = cnt + 1;
end
display(cnt)
end
  2 Comments
Munir Baldomero
Munir Baldomero on 3 Jun 2022
That is how the software generate the data from the upper-air sounding. There are missing value due to lack of data obtained from the balloon flight

Sign in to comment.

Accepted Answer

Jon
Jon on 3 Jun 2022
Edited: Jon on 3 Jun 2022
I'm not quite clear what you want to do with the data, but I'm assuming you want to get the text table into some form that you can extract desired numerical values out of it.
I used the MATLAB "Import Data" button on the HOME tab of the main MATLAB UI, and fiddled with the parameters to generate the attached function for reading your data into a table. The most important thing turned out to be using fixed width columns and dragging the sliders to the appropriate column widths.
Once you have the data into a table you can get for example the value of weak DCAPE 6.0 km, AGL
T = importfile('04JUNE2020_0000Z.txt',15,62)
T{T.Parameter=="DCAPE 6.0 km, AGL",'Weak'}
Weight Parameter Weak Moderate Strong
______ ____________________________________________ ____ ________ ______
1 "200 mb Wind Speed (kt)" NaN NaN NaN
1 "500 mb Wind Speed (kt)" NaN NaN NaN
1 "700 mb Wind Speed (kt)" NaN NaN NaN
1 "700 mb Dewpoint Depression (C)" NaN NaN NaN
1 "850 mb Wind Speed (kt)" NaN NaN NaN
1 "850 mb Dewpoint (C)" NaN NaN NaN
1 "700 - 500 mb lapse rate (C/km)" NaN NaN NaN
1 "Boyden Index" NaN NaN NaN
1 "BRN - Bulk Richardson No." NaN NaN NaN
1 "BRN Shear (m²/s²)" NaN NaN NaN
1 "CAP Strength" NaN NaN NaN
1 "CAPE 0-3 km, AGL" 0 NaN NaN
1 "CAPE Total" 0 NaN NaN
1 "Craven SigSvr Parameter (mixed-layer lift)" NaN NaN NaN
1 "CT - Cross Totals" NaN NaN NaN
1 "DCAPE 6.0 km, AGL" 9 NaN NaN
1 "Delta Theta-e (ePT)" NaN NaN NaN
1 "EHI - Energy Helicity Index" NaN NaN NaN
1 "GOES HMI (Hybrid Microburst Index)" NaN NaN NaN
1 "Hail (cm)" NaN NaN NaN
1 "HI - Humidity Index" NaN NaN NaN
1 "JI - Jefferson Index" NaN NaN NaN
1 "K Index" NaN NaN NaN
1 "KO Index" NaN NaN NaN
1 "LFC-LCL height (m)" NaN NaN NaN
1 "LFC - Level of Free Convection (mb)" NaN NaN NaN
1 "LI - Lifted Index" NaN NaN NaN
1 "MDPI - Microburst Day Potential Index" NaN NaN NaN
1 "NCAPE (Normalized CAPE)" 0 NaN NaN
1 "S Index" NaN NaN NaN
1 "SCP - Supercell Composite Parameter" 0 NaN NaN
1 "Severity - Thunderstorm Severiry Index" 4.9 NaN NaN
1 "SHIP - Significant Hail Parameter" NaN NaN NaN
1 "SI - Showalter Index" NaN NaN NaN
1 "srH - storm-relative Helicity (0-3 km)" 1 NaN NaN
1 "STP - Significant Tornado Parameter" 0 NaN NaN
1 "Surface Dewpoint (C)" NaN NaN 22.9
1 "SWEAT Index" NaN NaN NaN
1 "T2 Gust (kt)" NaN NaN NaN
1 "TI - Thompson Index" NaN NaN NaN
1 "TQ Index" NaN NaN NaN
1 "TT - Total Totals" NaN NaN NaN
1 "VGP - Vorticity Generation Parameter" 0 NaN NaN
1 "VT - Vertical Totals" NaN NaN NaN
1 "Waterspout Index" NaN NaN NaN
1 "WBZ - WetBulb Zero Hgt (ft,AGL) *" NaN NaN NaN
1 "Windex (kt)" NaN NaN NaN
1 "WMSI - Wet Microburst Severity Index" NaN NaN NaN
ans =
9
  6 Comments

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!