MATLAB: I have a row of 1308 values and I need the total every 12 rows. So I need the sum of rows 1-12 and then again for the next 12 numbers 1 1 1 5 5 1 1 1 10 1 1 1 so basically I need the sum of all these numbers in this entire column for the 12 rows and then i need to get the values for the next 12 rows Best Answer Maybe you can use reshape and sum function.For example:a = rand(1, 1000); % this create a rand vector of 1000 dimsb = reshape(a, 10, 100); % this convert vector a to a matrix of 10 rows and 100 columnsc = sum(b); % this calculate the sum of each column Related SolutionsMATLAB: How to calculate averages for each rows from a specific column to a specific column in a matrix Here is one way, using the movmean function.A = ...[1 2 3 4 5 67 8 9 10 11 1213 14 15 16 17 1819 20 21 22 23 2425 26 27 28 29 3031 32 33 34 35 36];NC = 2; % This is the number of columns you want to average over.tmp = movmean(A,NC,2); % Note that the "2" here is dimension to average over, NOT the number of columnsB = tmp(:,NC:NC:end); MATLAB: Average sections of matrix I am not certain that I understand the result you want.Try this:M = rand(31, 109); % Original MatrixCols = [ones(1, fix(size(M,2)/25))*25 rem(size(M,2),25)]; % Create Column Sub-Sections C = mat2cell(M, size(M,1), Cols); % Cell Array Of Sub-SectionsCmean = cellfun(@(x)mean(x,2), C, 'Uni',0); % Row Means For Each SectionMmean = cell2mat(Cmean); % Convert To Double Matrix Of Row Mean Vectors For Each Sub-Section Related QuestionSum specific intervals of rows for a matrixCumulative sum of some columns of matrix
Best Answer