Running time Average of column values

2 次查看(过去 30 天)
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
编辑: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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by