Clear Filters
Clear Filters

MATLAB Textread Issue

2 views (last 30 days)
Andrew
Andrew on 22 Jan 2011
I am writing a program but I need to read in a long text file. I've always had issues doing this. The text file I must read follows:
GFZ_FITXYZ_950221_IRVS
2007 11 5 0 0 0.0 -1783588.462281 -1267259.934283 6482787.305390
8003 3902 1 -5733.994395904 -4386.447880447 -2439.128234213
34 192 0 14155.0 3431938.908827 -12559.570510564
GFZ_FITXYZ_950221_IRVS
2007 11 6 0 0 0.0 -3750140.304420 -2955751.991962 -4898427.382851
8003 3902 2 4192.426457933 3506.182104387 -5327.434574051
31 192 0 14154.0 -11604319.679233 2371.173988270
GFZ_FITXYZ_950221_IRVS
2007 11 7 0 0 0.0 5305023.553058 3824897.277118 -2046913.442892
8003 3902 3 2047.542381968 1059.158266536 7273.506285649
28 193 0 14154.0 7083007.387284 10380.206934153
GFZ_FITXYZ_950221_IRVS
2007 11 8 0 0 0.0 -984513.612261 -545979.895928 6747797.562538
8003 3902 4 -6191.583603810 -4259.587705721 -1254.985695427
25 193 0 14153.0 5217304.054349 -11706.157004958
GFZ_FITXYZ_950221_IRVS
2007 11 9 0 0 0.0 -4520041.121990 -3118222.349464 -4078054.336345
8003 3902 5 3610.233289070 2776.929681410 -6130.555206664
22 194 0 14153.0 -11716317.807800 256.607763816
GFZ_CONDOI_921001_IRVS
2007 11 10 0 0 0.0 5187779.953005 3272833.237108 -3059296.696000
8003 3902 6 3039.828645643 1563.310433224 6816.358667000
19 194 0 14152.0 5401316.494112 11419.497745867
I have written a code segment to read this but it doesn't work and I've been fooling around with it for an hour. Can anyone help me correct it?
[name,year,month,day,hour,mins,secs,x,y,z,sic,eph,nno,x_v,y_v,z_v,x_pol,y_pol,ddrate,bbb,ccc,ddd]=textread('graceA_irvs_071105_0.dat','%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f')
This is just the generic one everytime I try to add end of line to go to the next line and begin reading in more values it doesn't work. It ends up with a huge fname variable and no other variables near the end T_T.

Accepted Answer

Oleg Komarov
Oleg Komarov on 22 Jan 2011
Try to consider endofline chars as whitespace:
[name,year,month,day,hour,mins,secs,x,y,z,sic,eph,nno,x_v,y_v,z_v,x_pol,y_pol,ddrate,bbb,ccc,ddd] = textread('graceA_irvs_071105_0.dat','%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','whitespace',' \b\t\n\r');
Oleg

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!