Running time Average of column values

조회 수: 7(최근 30일)
Yash Bhati
Yash Bhati 2021년 10월 19일
편집: Yash Bhati 2021년 10월 19일
I have to imported data form my simulation and made a table which is of Nx1 size.(N depends on number of output which i get from my simulation)
suppose my Table1 looks likes
1.10
2.20
3.20
4.40
......
now what i want is to create another Table2 which has running average of values from Table1, So my Table2 would look like
1.10
2.(10+20)/2
3.(10+20+20)/3
4.(10+20+20+40)/4
.....

채택된 답변

KSSV
KSSV 2021년 10월 19일
If A is your column array.
iwant = cumsum(A)./(1:numel(A))
  댓글 수: 2
Yash Bhati
Yash Bhati 2021년 10월 19일
Thank you for your answers. Movmean works well. Code i wrote was this.
t=length(A);
M = movmean(A,[t 0]);
Although script as mentioned by KSSV (iwant = cumsum(A)./(1:numel(A))) works well but had to exract data from diagonal matrix.
Thank you all.

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by