I dont know why the final 98 readings don't get averaged.. any ideas?
Disclaimer: I don't know a thing about MatLab.
The code posted takes only the number of whole sets and reshapes them into a matrix, so of course the remaining data are not averaged.
For example
17899 / 10 * 0.2 = 357.98
50 * 0.98 = 49
or..
17899 % ((int)(17899 / 10 * 0.2)) = 49
So the code schwaip posted discards 49 data that do not fit into a whole set as defined by the period, in the case of my example, 10 seconds
This may be desirable, since the first 357 sets represent data for 10 seconds, and the remaining 49 data represent only a 9.8 second period. It is not technically accurate to compare the two as they represent different things and there is no real way to substitute missing data.
If you want to process the remaining data into an average, then you can isolate them with the following psuedo code, reusing schwaips variable names in bold and assuming 1 based vectors:
Code:
if (Length(data) != maxind)
{
LastSetLength = Length(data) - maxind;
LastSetAvg = Sum(data[maxind + 1 to Length(data)]) / LastSetLength;
LastSetPeriod = LastSetLength * dt;
}
You could include this figure with an annotation stating that it is derived from data for a different period of time, and give the period. I don't see much worth in that, though.
Edit: Apparently vectors in MatLab are 1-based.