# Thread: MATLAB: reading multiple rows as one

1. ## 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.

2. Originally Posted by ERiveraSr
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