calling multiple rows from a spreadsheet

2 views (last 30 days)
Nenad
Nenad on 6 Oct 2011
I have data from a solar panel from a 30 day period. It is instantaneously recorded at 10 minute intervals. The value is stored in the logger. What I am trying to do is plot an average the entire month. I would need to take each individual point from each day and group them with the corresponding point of the rest of the days. Then plot a graph of an average curve.
for example: On July 7th, at 10:30 AM, the value is x. The next day, at 10:30 the value is y, etc, etc.
There are 144 points in a day.
I would end up with a 144x2 matrix, with average points for every time period.
what would be the best way to call every 144th column? using a for loop??
Thanks for any help.

Answers (2)

Fangjun Jiang
Fangjun Jiang on 6 Oct 2011
a=1:144*30;
b=a(1:144:end);

Walter Roberson
Walter Roberson on 7 Oct 2011
I suggest you reconsider how you do this, turning instead to use accumarray()
min10slot = 1 + (months - 1) * 144 + hours * 6 + floor(mins/10);
avgval = accumarray(min10slot(:), values(:), [], @mean);
This constructs a series of indices by 10 minute intervals for every day, and folds in the month information in to the index information. The +1 is to ensure the first one starts at 1 instead of 0.
The accumarray() will total the values that fit in to each 10 minute slot within each month, and will calculate the mean of what found its way in to each slot.
January would be slots 1 to 144, February 145 to 288, and so on. You could reshape() to make it easier to chart.
You can convert back to time of day via
temp = mod((index - 1), 144);
minute = mod(temp,6) * 10;
hour = floor(temp / 6);
Mind you the formula do simplify if your data is already broken up by month; the above is the generalization to do year(s) at a time.
If you do use accumarray, you should decide what you want for slots there happens to be no data at all for (e.g., if it was always turned off at midnight until 3AM). By default those would show up as 0's, but you could easily change that to NaN or another fixed constant.

Community Treasure Hunt

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

Start Hunting!