-2

I need your help. I have one data file like below,

frames.trr  frame   0:00                    
    natoms= 1000    step=   0   time=0.0000000e+00  lambda= 0
    box (3x3):                  
    box[    0]={    1.72E+01    0.00E+00    0.00000e+00}        
    box[    1]={    0.00E+00    1.52E+01    0.00000e+00}        
    box[    2]={    0.00E+00    0.00E+00    1.53731e+01}        
    x   (1000x3):                   
    x[  0]={    1.22E+01    1.06E+01    1.33530e+01}        
    x[  1]={    1.15E+01    7.92E+00    5.99100e+00}        
    x[  2]={    1.42E+01    1.30E+01    1.52530e+01}    

                        ....

    x[1000]={   1.42E+01    1.30E+01    1.52530e+01}    
    v   (1000x3):                   
    v[  0]={    2.40E-01    -1.34E-01   -2.53100e-01}       
    v[  1]={-6.91001e-02    -8.42E-02   -2.24600e-01}           
    v[  2]={-8.99700e-01    1.50E-02    5.57800e-01}

                        ....

    v[1000]={-8.99700e-01   1.50E-02    5.57800e-01}
frames.trr  frame   1:00                    
    natoms= 1000    step=   2   time=2.0000001e-03  lambda= 0
    box (3x3):                  
    box[    0]={    1.72E+01    0.00E+00    0.00000e+00}        
    box[    1]={    0.00E+00    1.52E+01    0.00000e+00}        
    box[    2]={    0.00E+00    0.00E+00    1.53731e+01}        
    x   (1000x3):                   
    x[  0]={    1.22E+01    1.06E+01    1.33525e+01}        
    x[  1]={    1.15E+01    7.92E+00    5.99055e+00}        
    x[  2]={    1.42E+01    1.30E+01    1.52541e+01}        
    x[  3]={    1.35E+01    1.27E+01    1.08896e+01}    

                        ....

    x[1000]={   1.42E+01    1.30E+01    1.52530e+01}    
    v   (1000x3):                   
    v[  0]={    2.40E-01    -1.34E-01   -2.53100e-01}       
    v[  1]={-6.91001e-02    -8.42E-02   -2.24600e-01}           
    v[  2]={-8.99700e-01    1.50E-02    5.57800e-01}

                        ....

    v[1000]={-8.99700e-01   1.50E-02    5.57800e-01}

I would like to read the numbers (1.22E+01 1.06E+01 1.33530e+01) from three columns at each line and skip other headlines. How do I do this?

sco1
  • 12,154
  • 5
  • 26
  • 48
S.Baek
  • 1
  • 1
  • This is not a trivial problem and StackOverflow is not a code writing service. As a starting point I suggest reading MATLAB's [low level IO](http://www.mathworks.com/help/matlab/low-level-file-i-o.html) documentation. – sco1 Feb 24 '16 at 12:16

1 Answers1

0

You could use MATLAB's data import wizard. You can specify your delimiters, like this: enter image description here

Access it on the Home ribbon (Import Data, on the right): enter image description here

It will generate a script for you, which you can reuse for many data files. From there, you can use a simple for loop to extract the numbers which follow "X[ 0]={"

wdickerson
  • 849
  • 7
  • 8