MATLAB: How to average specific rows of all columns averaging specific rows of all columns i am having 100×32 matrix in my data set. i would like to average 20 rows of all columns, like first 20rows average, next 20 and so..on… can any one help in this problem. Best Answer If I understand your question correctly, you can use the movmean command:% Some made-up dataA = rand(100,32);N = 20;movingAverageA = movmean(A,[(N-1) 0]); % Trailing average of N rowsoutput = movingAverageA(N:N:end,:); Related SolutionsMATLAB: How to get average of multiple rows and subtract from one group of average to another M = your matrix with 10039 rows and 64 columnsN = 30;whole_blocks = floor(size(M,1)/N);leftover = size(M,1) - whole_blocks * N;last_whole = whole_blocks * N;whole_mean = reshape( mean(reshape(M(1:last_whole, N, [])), 2), whole_blocks, [] );extra_mean = mean(M(last_whole+1:end, :),1);overall_mean = [whole_mean; extra_mean]; MATLAB: How to calculate variance A= *your matrix*V = var(A);If A is a matrix whose columns are random variables and whose rows are observations, V is a row vector containing the variances corresponding to each column. Related QuestionAveraging 20 values within 1000 data pointsColoring of different index/numbered points
Best Answer