"Jakob " <email@example.com> wrote in message news:firstname.lastname@example.org... > Hey guys, i want to use in this case 360 values in a matrix to generate a > mean in a new matrix. And i want a loop to continue doing that for the > entire first matrix which in this case consist of 15440 values.
So what do you want to do with the left-over 320 elements of your matrix?
>> [360*42, 15440-360*42]
> I've tried this : > > for N = 1:42 > X=0; > for n = 1:360 > X=X+DATA((360*N-360)+n); > n=n+1; > end > mean(N)=X/360; end > > The mean matrix however gets bigger than the 42 times im running it, and > only the first mean seems to be realistic.
IF your matrix size were an integer multiple of the size of your "block" I would suggest RESHAPE and calling the MEAN function with a dimension input argument, but since it's not you need to decide first what to do with the leftover chunk. Zero-pad to make your matrix size a multiple of 360, ignoring the extra elements, or extracting the extra elements and taking their MEAN (which would sum and divide by 320 instead of dividing by 360) separately are three possible options.