Results 1 to 2 of 2

Math Help - MATLAB: reading multiple rows as one

  1. #1
    Newbie
    Joined
    Mar 2008
    Posts
    7

    MATLAB: reading multiple rows as one

    I'm having a problem reading more than one line of data at once.
    I have thunderstorm cloud data in the form of a .txt file. Every row of data consists of different variable for up to six clouds. For example.
    cellnum = number of clouds
    latitude
    longitude
    area
    temperature
    cooling rate
    The data looks like this
    6
    42.0500 41.9400 41.7800 41.8300 41.6600 41.7500
    -81.2000 -81.3500 -81.4500 -81.2800 -81.1800 -81.0100
    347.071 641.914 429.008 375.071 796.930 545.471
    -22.4964 -20.6864 -18.2962 -19.8414 -23.9924 -26.2238
    -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0
    My problem is that the text file I have goes up to only 6 columns, therefore, when there are more than six clouds in a trajectory, the seventh number goes to the next row.
    What I want to do is tell matlab that if cellnum > 6, it should read two lines. The total number of cells is 28, but if i can learn to program it to read two line, I can do three, four or even five.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by ERiveraSr View Post
    I'm having a problem reading more than one line of data at once.
    I have thunderstorm cloud data in the form of a .txt file. Every row of data consists of different variable for up to six clouds. For example.
    cellnum = number of clouds
    latitude
    longitude
    area
    temperature
    cooling rate
    The data looks like this
    6
    42.0500 41.9400 41.7800 41.8300 41.6600 41.7500
    -81.2000 -81.3500 -81.4500 -81.2800 -81.1800 -81.0100
    347.071 641.914 429.008 375.071 796.930 545.471
    -22.4964 -20.6864 -18.2962 -19.8414 -23.9924 -26.2238
    -99999.0 -99999.0 -99999.0 -99999.0 -99999.0 -99999.0
    My problem is that the text file I have goes up to only 6 columns, therefore, when there are more than six clouds in a trajectory, the seventh number goes to the next row.
    What I want to do is tell matlab that if cellnum > 6, it should read two lines. The total number of cells is 28, but if i can learn to program it to read two line, I can do three, four or even five.
    Look at the help for fscanf, with a bit of care you should be able to read anything.

    RonL
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 8
    Last Post: September 20th 2011, 01:42 PM
  2. next two rows
    Posted in the Number Theory Forum
    Replies: 2
    Last Post: March 6th 2011, 12:09 AM
  3. (Matlab) Image processing - Detect multiple circle
    Posted in the Math Software Forum
    Replies: 3
    Last Post: April 15th 2009, 09:09 AM
  4. Multiple array generation in Matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: January 29th 2009, 03:01 PM
  5. Am I Reading Too Much Into This?
    Posted in the Calculus Forum
    Replies: 4
    Last Post: July 9th 2008, 10:26 PM

Search Tags


/mathhelpforum @mathhelpforum