MATLAB: Mean of specific rows from one column columnmeanrows Hi, I want to find the mean of specific rows from one column, for example if I want to find the mean of rows 1, 3, 5, 6 and 7. How do I do this? I have attached an image of what this column looks like. Thank you. Best Answer This might work: mean(A([1, 3, 5, 6:7])) Related SolutionsMATLAB: How to calculate the mean of certain rows of a matrix based on specific column values This works:A = [ 123 1; 444 2; 634 1; 311 1; 111 2; 222 1; 312 1];Amean = accumarray(A(:,2), A(:,1), [], @mean) % Calculate MeansAmeanMtx = [Amean [1;2]] % Amean For The Appropriate Column #2 (For Demonstration Only, Can Be Deleted)Aresd = A(:,1)-Amean(A(:,2)) % Use The Second Column To Index ‘Amean’ To Calculate The ResidualsAmean = 320.4 277.5AmeanMtx = 320.4 1 277.5 2Aresd = -197.4 166.5 313.6 -9.4 -166.5 -98.4 -8.4EDIT — Added comment documentation. MATLAB: Matrix number of rows reduction to a smaller number of rows. Use this: % A is your input matrix and B is squeezed matrix for i=1:n idx=find(i==A(:,1)); B(i,:)=mean(A(idx,:),1); end Related QuestionFinding Rest of RowMean of row with column shiftedHow to automate the sequence of codeHow to find the average of certain rows in a column depending on the value of another column
Best Answer