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

조회 수: 5 (최근 30일)
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,
Gabe

채택된 답변

James Tursa
James Tursa 2019년 11월 25일
Hints:
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
Gabriel Berkhoudt
Gabriel Berkhoudt 2019년 11월 27일
James,
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?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by