for k=1:24n =24;for jj = numel(n):-1:1 cd = circshift(out2hourly{1}, [-(k-1) 0]); n1 = ceil((1:size(cd,1))'/n(jj)); out{k} = [cd(1:n(jj):end,1), accumarray(n1,cd(:,2),[],@max),... accumarray(n1,cd(:,3),[],@min),cd(24:n(jj):end,4)]; endend
Suppose the formula above. Out2hourly is a cell array that contains a matrix with 4 columns and 4000-5000 rows. I want to construct an array with accumulation meaning every 24 rows are summarized to one. The first column has the first value, the second column the maximum value of the 24 rows, the third column has the minimum value of the 24 rows and the last column contains the very last value of the 24 chain. The problem is that the last column will be x-1 rows. The rows of the columns 1-3 have x rows. Therefore I get the following error message:
Error using horzcatDimensions of arrays being concatenated are not consistent
I can solve this issue by removing the last row of the first three columns. Therefore I have rewritten the file as below but somehow it doesnt work and I get another error message
out{k} = [cd(1:n(jj):end-1,1), accumarray(n1,cd(1:end-1,2),[],@max),... accumarray(n1,cd(1:end-1,3),[],@min),cd(24:n(jj):end,4)];
Does anyone haven an idea how to resolve this?
Best Answer