How to load/import a text file with strange format in matlab -
i have extract data text file weird format matlab cannot since there text , functions know not work in case. data arranged in different sets (more 200) of 2000 values each.
here how formatted data in text file :
the first lines of set those
@legend string 0 "partition= 1 excit= 1 near/far= 1" #legend string 0 "lab energy = 737.0000" @s0 linestyle 1 # theta sigma it11 t20 t21 t22 kyy projectile 0.1000e-01 1.000 0.1000e-01 1.000 0.2000e-01 1.001 0.3000e-01 1.001
this goes on , on until
19.98 0.1659 19.99 0.1654 20.00 0.1649 end
the end text denotes end of set. then, new set begins
@legend string 1 "partition= 1 excit= 2 near/far= 1" #legend string 0 "lab energy = 737.0000" @s1 linestyle 2 # theta sigma it11 t20 t21 t22 kyy projectile 0.000 26.40 0.1000e-01 26.41 0.2000e-01 26.45 0.3000e-01 26.52
and until end.
as "headers" of each set same , number of lines per set same, extract sets want selecting rows of matrix want... how import text file matrix or anything?
thanks
you can use this
fid = fopen( 'file1.txt' ); tline = fgetl(fid); while ischar(tline) disp(tline) %your parsing code here tline = fgetl(fid); end fclose( fid );
Comments
Post a Comment