MATLAB: Importing data and plotting

data importtxt file

How can I load this txt file with some text at starting and numericals.I want to plot H,D,Z,F values aginst time see attached file plse

Best Answer

hello
impordata or readtable will do the trick
example with impordata :
importdata('abg20000212dminn.txt')
ans =
1466×1 cell array
{' Format IAGA-2002 |'}
{' Source of Data Indian Institute of Geomagnetism |'}
{' Station Name Alibag |'}
{' IAGA CODE ABG |'}
{' Geodetic Latitude 18.620 |'}
{' Geodetic Longitude 72.870 |'}
{' Elevation 0 |'}
{' Reported HDZF |'}
{' Sensor Orientation HDZF |'}
{' Digital Sampling 5.0 seconds |'}
{' Data Interval Type Average 1-Minute (00:30-01:29) |'}
{' Data Type Definitive |'}
{' # D-conversion factor 110800 |'}
{' # K9-limit |'}
{' # This data file was converted from INTERMAGNET CD-ROM |'}
{' # Format binary data. |'}
{' # A complete set is available on the INTERMAGNET CD-ROM. |'}
{' # Go to www.intermagnet.org for details on obtaining this product. |'}
{' # CONDITIONS OF USE: These data are for scientific/academic use |'}
{' # For any other applications see the 'Conditions of Use' published |'}
{' # on the INTERMAGNET web site - www.intermagnet.org |'}
{' # D conversion factor is a fixed value used to allow |'}
{' # Declination to be converted from minutes of arc to equivalent |'}
{' # nanoteslas. Set to H/3438*10000 where H is the annual mean |'}
{' # value of horizontal intensity. |'}
{'DATE TIME DOY ABGH ABGD ABGZ ABGF |'}
{'2000-02-12 00:00:00.000 043 99999.00 99999.00 99999.00 99999.00'}
{'2000-02-12 00:01:00.000 043 38132.70 -21.20 18442.20 99999.00'}
{'2000-02-12 00:02:00.000 043 38131.90 -21.20 18443.20 99999.00'}
{'2000-02-12 00:03:00.000 043 38132.20 -21.10 18443.90 99999.00'}
{'2000-02-12 00:04:00.000 043 38132.90 -21.10 18444.60 99999.00'}
{'2000-02-12 00:05:00.000 043 38132.00 -21.00 18445.70 99999.00'}
{'2000-02-12 00:06:00.000 043 38129.50 -20.80 18447.20 99999.00'}
{'2000-02-12 00:07:00.000 043 38129.00 -20.80 18448.00 99999.00'}
{'2000-02-12 00:08:00.000 043 38129.20 -20.80 18448.00 99999.00'}
.....
example with readtable
T = readtable(filename,'VariableNamingRule' ,'preserve');
M = table2cell(T)
M =
1454×12 cell array
Columns 1 through 6
{[NaT ]} {[NaN ]} {[NaN]} {[ 110800]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[NaT ]} {[NaN ]} {[NaN]} {[ NaN]} {[ NaN]} {[ NaN]}
{[2000-02-12]} {[00:00:00]} {[ 43]} {[ 99999]} {[ 99999]} {[ 99999]}
{[2000-02-12]} {[00:01:00]} {[ 43]} {[3.8133e+04]} {[-21.2000]} {[1.8442e+04]}
{[2000-02-12]} {[00:02:00]} {[ 43]} {[3.8132e+04]} {[-21.2000]} {[1.8443e+04]}
{[2000-02-12]} {[00:03:00]} {[ 43]} {[3.8132e+04]} {[-21.1000]} {[1.8444e+04]}
{[2000-02-12]} {[00:04:00]} {[ 43]} {[3.8133e+04]} {[-21.1000]} {[1.8445e+04]}
{[2000-02-12]} {[00:05:00]} {[ 43]} {[ 38132]} {[ -21]} {[1.8446e+04]}
............