MATLAB Answers

Adding a row to an unknown matrix - the row consists of the mean value of the columns of the unknown matrix.

6 views (last 30 days)
Add a row to the bottom of A that consists of the mean of each column of A and assign the resulting matrix to B.
I am trying to add a row into an unknown matrix - the row has to consist of the mean of the columns of the unknown matrix.
Does anyone have ideas?
Thank you,


Sign in to comment.

Accepted Answer

James Tursa
James Tursa on 25 Nov 2019
doc mean
The last row of the matrix A is A(end,:). Then ask yourself: What would be the indexing of one row beyond "end"?

  1 Comment

Gabriel Berkhoudt
Gabriel Berkhoudt on 27 Nov 2019
thanks for your response. It helped point me in the right direction.
I worked out, "A(end+1,:)=mean(A)" which, is perfect its what I need..EXCEPT I need the resulting matrix from the (A) and, A(end+1(mean(A)), to be under the variable B.
I'm not sure how I can do that aside from saying B=ans.
I have tried many different variations, and looked everywhere and I'm getting nothing.
Do you have any suggestions?

Sign in to comment.

More Answers (0)

Sign in to answer this question.