importdata-- matlab

source file: test.dat

***************************

Day1  Day2  Day3  Day4  Day5  Day6  Day7
95.01 76.21 61.54 40.57  5.79 20.28  1.53
23.11 45.65 79.19 93.55 35.29 19.87 74.68
60.68  1.85 92.18 91.69 81.32 60.38 44.51
48.60 82.14 73.82 41.03  0.99 27.22 93.18
89.13 44.47 17.63 89.36 13.89 19.88 46.60

*******************

matlab code:

A = importdata('test.dat',delimiterIn,headerlinesIn)

- loads data from *ASCII* file, filename, or the clipboard
- delimiterIn :: column separator character, such as empty space is expressed as  ''
- headerlinesIn :: reading numeric data starting from line *headerlinesIn+1*.

 

>> a= importdata('test.dat','', 2)
a =

  scalar structure containing the fields:

    data =

     Columns 1 through 4:

       23.11000   45.65000   79.19000   93.55000
       60.68000    1.85000   92.18000   91.69000
       48.60000   82.14000   73.82000   41.03000
       89.13000   44.47000   17.63000   89.36000

     Columns 5 through 7:

       35.29000   19.87000   74.68000
       81.32000   60.38000   44.51000
        0.99000   27.22000   93.18000
       13.89000   19.88000   46.60000

    textdata =
    {
      [1,1] = Day1  Day2  Day3  Day4  Day5  Day6  Day7
      [2,1] = 95.01 76.21 61.54 40.57  5.79 20.28  1.53
    }
    colheaders =
    {
      [1,1] = 95.01
      [1,2] = 76.21
      [1,3] = 61.54

 

posted @ 2019-03-06 16:05  kaiming_ai  阅读(305)  评论(0编辑  收藏  举报